ecmascript-types
ecmascript-types copied to clipboard
Calculating the size of value types and ensuring compile-time optimization
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.