3 ms·
"This could be fixed by switching to keywords, which I prefer for this reason" ~ could be named unique_ptr and @ something like shared_ptr. Genius!
by jhasse 13y ago
"This could be fixed by switching to keywords, which I prefer for this reason"
~ could be named unique_ptr and @ something like shared_ptr. Genius!
- anonymous 13y agoOr maybe we could allow types or type annotations to be written using only non-alphabetic characters and then ~ could be ~ and @ something like @ and my fingers won't break from typing. I do prefer having sigils for types that enrich other types to make them obviously different from types that are parametrized by another. Compare ~string to list<string> - the first is a uniquely owned string, the second is a list of string. ~ is an adjective and list is a noun. ~string is a string with such-and-such memory semantics; list<string> is a list that happens to contain strings.
- copx 13y ago..or given that they like 1970s style abbreviated identifiers so much: "upt" and "spt" Looking forward to writing: "let mut foo = upt .."
- dbaupp 13y agoOne of the best bits of Rust is the low syntactic noise of ~T instead of unique_ptr<T>, since it's so common. (And similarly with @, which is less common, except in the compiler itself, where it is used all the time.) Maybe I'm exaggerating a bit, but it really seems to work well after using it for a little.
- bjz_ 13y agoI agree with you on that. It's a tad intimidating at first, but if you go with the flow you find it really cuts down on the noise. I'm surprised so many folks are arguing the opposite, to be honest.