On 4/23/13 8:11 AM, Niko Matsakis wrote:
Thanks for your proposal. We've been through a number of rounds with the
lifetime syntax, including an earlier scheme that was quite similar to
what you propose in some regards (there was a single anonymous lifetime
parameter that was used whenever you wrote `&T`, which meant that yes
you often did not need to use explicit lifetime parameter names).

However, we found that this was ultimately more confusing to people than
helpful. One of the goals of the current syntax was to make the
mechanism of named lifetimes more explicit and thus more clear to the
reader. Smarter defaults have the disadvantage that they often obscure
the underlying system, making it harder to learn what's really going on.

In practice,named lifetimes don't seem to be that common, at least for
me. We should do some numerical analysis, but I've found subjectively
that most functions simply consume data and do not return pointers. This
is particularly true for "non-library" code, and even more true with
judicious use of `@` pointers (it is often not worth the trouble to
avoid the GC; it can make life much easier, that's what it's there for).

Another thing I like about the current system is that it has nice pedagogical aspects. Where named lifetimes come in is in two well-defined places: (a) returning a reference; (b) stuffing a reference into a data structure. This allows programmers to write lots of programs without having to know how to use named lifetimes, and it allows the compiler to be very clear in error messages about where a named lifetime must be used.

Patrick

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to