Carp icon indicating copy to clipboard operation
Carp copied to clipboard

Avoid printing lifetimes sometimes, and also print them in a nicer way

Open eriksvedang opened this issue 5 years ago • 12 comments

Right?

Would make things a lot more readable...

eriksvedang avatar Nov 16 '20 19:11 eriksvedang

Also, we should probably make them stand out more visually.

eriksvedang avatar Nov 16 '20 19:11 eriksvedang

type currently prints lifetimes with angle brackets:

鲤 (type "foo")
=> (Ref String <a>)

Maybe we can adopt that everywhere?

Actually, it'd be good to adopt this in the parser for type sigs even, since it would help distinguish between type vars and lifetime vars (which would help w/ #910

scolsen avatar Nov 17 '20 17:11 scolsen

Yeah, some kind of signifier would be great. Perhaps angle brackets are OK, though they are a bit annoying to type – any other ideas?

eriksvedang avatar Nov 17 '20 21:11 eriksvedang

A sigil/prefix (like & or @) would be better imo.

eriksvedang avatar Nov 17 '20 21:11 eriksvedang

I think & makes a lot of sense since it's already a shorthand for refs!

scolsen avatar Nov 17 '20 21:11 scolsen

Oh, I actually meant similar to those. I think the signatures will be too hard to visually parse if we “overload” &, even though the compiler can discern them.

eriksvedang avatar Nov 17 '20 21:11 eriksvedang

Ahh gotcha, maybe * for nods to pointers?

scolsen avatar Nov 17 '20 21:11 scolsen

~t .t

eriksvedang avatar Nov 17 '20 21:11 eriksvedang

~ is nice too

scolsen avatar Nov 17 '20 21:11 scolsen

*

Yes that could work too.

eriksvedang avatar Nov 17 '20 21:11 eriksvedang

Don’t forget that ~ is already used for calling function references as well. That’s not a deal breaker in refs, but could be visually, confusing.

hellerve avatar Nov 18 '20 08:11 hellerve

I really like <a> in term of readability but I understand that might make parsing harder. I feel in that case it's better to optimise for readability than "type-ability" given how often you have manually specify lifetimes.

TimDeve avatar Nov 18 '20 11:11 TimDeve