Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



All 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.


I 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.


Sure, and I think that's insightful: what you may consider a mess, I may consider orthogonal!


This feels disingenuous. I have a hard time imagining a case where someone would find this confusing.


Rust 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.


While that's true, all three of these uses pre-date Rust 1.0, so there was total freedom in this case.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: