3 ms·
A maybe<T> in a language with halfway decent support for sum types is most likely a tagged pointer to a T, if it is reified at all. A clever compiler is likely
by codebje 9y ago
A maybe<T> in a language with halfway decent support for sum types is most likely a tagged pointer to a T, if it is reified at all.
A clever compiler is likely to do the same thing for a pair of (bool, T): represent the bool as a tag in the pointer, store the T. If the value is reified at all.
What new run-time failure modes do you get with optional? Is it just what happens when you blithely ignore the "nothing" possibility and attempt to extract the contained value "on faith" ?