One of the hopes is that it's usually not necessary to write those lifetimes explicitly in most programs, unless you're doing something unusual.
If you could go back and change it, what would you have used for the lifetime syntax?
One of the hopes is that it's usually not necessary to write those lifetimes explicitly in most programs, unless you're doing something unusual.
If you could go back and change it, what would you have used for the lifetime syntax?
&'a X
looks less like Perl / line noise than this:
&@a X
. In any case, not something we'd be likely to change at this point, but I agree that ' is effectively "arbitrary unique symbol with no evocative meaning".
(Arguably the same is true for things like & for "address of", but that has a long history in many languages which makes it more intuitive for current developers.)
Other than 'static, a Rust beginner is unlikely to run into any lifetime with a meaningful name for quite a while. If when learning a new language you only ever saw variables named a, x, t, s, v and m it's not a big jump to guess that p, z and b would be allowed as well, but would you assume that in fact the language allows big_set and old_corp_logo as identifiers and it just forgot to mention that ? I'm not sure I would.
The Rust standard library does have lifetimes with reasonable names, for example std::thread::Scope needs two lifetimes and it names them 'scope and 'env which, although brief, are clearly not single letters. But most of the library and documentation doesn't bother with meaningful names, since it doesn't have anything worth saying about the lifetime, e.g. the signature of str::ends_with:
pub fn ends_with<'a, P>(&'a self, pat: P) -> bool
where P: Pattern<'a>,
<P as Pattern<'a>>::Searcher: ReverseSearcher<'a>I think it'd be a really good idea for the standard library to change many of its lifetimes to be descriptive, to encourage others to do the same. With my libs-api team hat on, I'd happily merge PRs that do that. (In small batches, please, not the whole library at once.)
&x\a
The current tick is much easier on the eyes.