A keyword or function that returns the number of bytes of an object. This would include class value types which have a fixed size.
Languages handle this slightly differently, but with similar results. C++ has a sizeof T keyword. C# has sizeof(T).
Since value types aren't Objects I find the idea of Object.size(...) or Object.size<T>() weird. Also I'd prefer more of a compile-time and runtime compatible method that is compiled away when applicable. Getting the size of uint8 for instance might be more readable than writing 1, but I'd hate if calculating the size had any performance implications.
A keyword or function that returns the number of bytes of an object. This would include class value types which have a fixed size.
Languages handle this slightly differently, but with similar results. C++ has a
sizeof T
keyword. C# hassizeof(T)
.Since value types aren't Objects I find the idea of
Object.size(...)
orObject.size<T>()
weird. Also I'd prefer more of a compile-time and runtime compatible method that is compiled away when applicable. Getting the size of uint8 for instance might be more readable than writing 1, but I'd hate if calculating the size had any performance implications.