It might be more instructive to list some exceptions:
- As described elsewhere in this thread, Julia is able to optimize Array<Option<X>> internally into a bitfield and a tightly-packed array of X
- Rust can use knowledge of a type's valid values to optimize Option<T> into something the same size of T for common T (pointers, arrays, etc, also notably I think user-defined enums which aren't exhaustive of their value space) - but as far as I know it cannot do what Julia does, you need to reach for e.g. https://docs.rs/vec-option/latest/vec_option/
- This is somewhat the raison d'etre for Jai, if it ever gets released.
to make it obvious, post some code.
bool m_initialized ;
storage_type m_storage ;FWIW, we have had this discussion a few months ago on HN.
(The compiler is allowed to improve this, but it won't.)
But those languages are very good at pretending they mix the two concepts.
for example?