3 ms·
I'd like to mention that we've been recently discussing ways of getting rid of the `::<>` syntax. Then mem::size_of::<T>() would be mem::size_of<T>()
by steveklabnik 12y ago
I'd like to mention that we've been recently discussing ways of getting rid of the `::<>` syntax. Then
mem::size_of::<T>()
would be
mem::size_of<T>()
which is less visually noisy. This syntax is probably the noisiest thing we haven't cleaned up yet.
- nixpulvis 12y ago+++++1
- andreasvc 12y agoThat still has lots of noise, arguably. Angular brackets somehow feel more noisy to me than the other brackets/braces, they work better as arrows and inequality operators. A single colon would also look better, I think, and the underscore could be dropped...
- pcwalton 12y ago: doesn't work because that's for type ascription (i.e. specifying what the type of something is). The angle brackets were chosen because they match the way nearly all C-family languages except D notate generics: C++, Java, C#, Swift, Dart, TypeScript, ActionScript, … The underscore improves readability here, IMO. We use underscores where they improve readability, similarly to PEP 8.
- MichaelGG 12y agoFor a constant like size_of, can you not eliminate the function call and make it a value? Just mem::size_of<T> ?
- pcwalton 12y agoNot without associated constants, which Rust does not yet support (and likely will not until after 1.0).
- pitterpatter 12y agosize_of isn't really a function but a compiler intrinsic.
- keeperofdakeys 12y agoAnother one I've seen discussed is mem::size_of[T](). Though I can't find any references about it online.
- steveklabnik 12y agoThere was an RFC: https://github.com/rust-lang/rfcs/pull/148 https://github.com/rust-lang/rfcs/pull/148 The author closed it after finding that there were no non-subjective reasons. Moving to []s causes other ambiguities.