4 ms·
> I just think it is a worthy goal to strive to make code > look somewhat simple, To be clear, I do as well. Some things are just inherently complex, though.
by steveklabnik 10y ago
> I just think it is a worthy goal to strive to make code
> look somewhat simple,
To be clear, I do as well. Some things are just inherently complex, though.
> could perhaps the compiler infer that?
The only reason they're added here is that they're not able to be inferred, and the reason they're all the same is that you're explicitly connecting the lifetime of each of these things.
> it kind of strikes me as looking more "complected" than "complex".
nom is for building extremely fast, extremely low-overhead parsers. When you're trying to do stuff like that, you can't always afford convenience stuff. Consider if you had to write all the code the macros generate by hand!
- e12e 10y ago> The only reason they're added here is that they're not able to be inferred, and the reason they're all the same is that you're explicitly connecting the lifetime of each of these things. Is the default of having them all be implicitly different, or unlinked, lifetimes very useful?
- steveklabnik 10y agoIf you don't write anything at all, the "lifetime elision rules" kick in: http://doc.rust-lang.org/stable/book/lifetimes.html#lifetime-elision http://doc.rust-lang.org/stable/book/lifetimes.html#lifetime... We used to only have the first of those three rules. When we added the other two, almost 90% of lifetime annotations in function declarations were able to be removed from the compiler and standard library.