4 ms·
possible for the Rust compiler to infer most/all lifetimes) I'd be interested to learn why you think this is possible. As you point out yourself, by Rice's
by mafribe 7y ago
possible for the Rust compiler
to infer most/all lifetimes)
I'd be interested to learn why you think this is possible. As you point out yourself, by Rice's theorem, precise lifetimes are not statically decidable. Rust's lifetimes are essentially based on nesting (think well-balanced brackets) and tracked by enriching the standard Damas-Hindley-Milner approach with a notion of affin-ness which is a weakening of Girard's linearity. Circular data structures immediately violate affine-ness. What mechanism do you propose to get around this conundrum?
- sanxiyn 7y agoI know this is possible because Rust already does this. Rust's types in closures can be fully inferred. Try replacing all Rust functions with closures. It goes surprisingly far.
- Hercuros 7y agoI think that for function definitions in Rust you would in principle be able to leave out lifetime annotations on arguments/return values in more cases than is currently allowed by lifetime elision. I believe they don't allow this since it can become very confusing if the lifetimes are not written out when there are multiple references arguments. I'm not entirely sure about this, though.
- lllr_finger 7y ago"All" might not be possible, but every Rust release tends to see improvements in lifetime elision. I just went through a few Rust apps I wrote 6 months ago and was able to get rid of nearly every explicit lifetime annotation thanks to improvements. So there's definitely room for improvement, but also good progress being made.
- timw4mail 7y agoI'm not sure this would be possible for a standalone library, compared to a self-contained program, either.