4 ms·
I don't know if this qualifies as inconsistent, but: `impl T for for<'a> fn(&'a u8) {}` The `for` word here is used in two different meanings, both different
by dlisboa 1y ago
I don't know if this qualifies as inconsistent, but:
`impl T for for<'a> fn(&'a u8) {}`
The `for` word here is used in two different meanings, both different from each other and from the third and more usual `for` loop.
Rust just has very weird syntax decisions. All understandable in isolation but when put altogether it does yield a hard to read language.
- steveklabnik 1y agoAll three have the same underlying idea: do this for every thing of that. In the first case, it's implement a trait for a type. In the second case, it's "for all choices of the lifetime" and for a for loop, it's do something for each element of a collection.
- dlisboa 1y agoI understand how that seems logical in isolation but it's just not how syntax is usually read by people. It's done so as part of a reading context instead of as separate syntatical tokens. The underlying idea is not the same for the reader because the context is vastly different.
- wtetzner 1y agoThis feels disingenuous. I have a hard time imagining a case where someone would find this confusing.
- steveklabnik 1y agoSure, and I think that's insightful: what you may consider a mess, I may consider orthogonal!
- NobodyNada 1y agoRust tends to prefer reusing keywords (in unambiguously different contexts) rather than introducing new ones, because adding a new keyword is a backwards compatibility break that requires a new language edition and creates migration pain for anyone who had an identifier with the same name as the new keyword.
- steveklabnik 1y agoWhile that's true, all three of these uses pre-date Rust 1.0, so there was total freedom in this case.