4 ms·
(Maybe Steve is around) Why did Rust go with the IMHO ugly closure syntax of |stuff| ? I think that stuff -> is much nicer to look at... :( Also
by oblio 9y ago
(Maybe Steve is around)
Why did Rust go with the IMHO ugly closure syntax of
|stuff|
?
I think that
stuff ->
is much nicer to look at... :(
Also, not presented here, but ‘ is also kind of ugly, was there no short keyword that could have been used? “life or “lt” for “lifetime”? “span”?
- Thiez 9y agoThat closure syntax has been around longer than Steve. So I take it you would like to be able to declare your references as `&life of brian`?
- oblio 9y agoHeh, who knows, maybe Python adds this feature for Python 4 :p
- steveklabnik 9y agoAs my sibling says, it was there before me. Ruby and smalltalk also use this syntax, so it’s not without precedence. As for lifetimes, that syntax is from OCaml, though they use it for something else. “life” and “lt” seem too short, “span” is overloaded. We tried to explore options but none were clearly better, so we kept what we had.
- mercurial 9y ago> As for lifetimes, that syntax is from OCaml, though they use it for something else. I hadn't noticed the similarity but it makes sense. This is the OCaml syntax for generics, eg: type 'a list_with_generic = 'a list;
- steveklabnik 9y agoYeah, it's also not as different as it sounds, as lifetimes are fundamentally generics, just of a different kind than types.