ecmascript-types icon indicating copy to clipboard operation
ecmascript-types copied to clipboard

Calculating the size of value types and ensuring compile-time optimization

Open sirisian opened this issue 3 years ago • 0 comments

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.

sirisian avatar Nov 28 '22 01:11 sirisian