3 ms·
Something like String|NoAnswer|None doesn't sound too bad to me here...
by cubefox 3y ago
Something like String|NoAnswer|None doesn't sound too bad to me here...
- Skeime 3y agoExcept that NoAnswer has none of the language’s (and it’s library’s) support for the built-in None. And you might run into problems when trying nest the data structure, which might be a reasonable thing for your users to do.
- cubefox 3y agoI just think that the nesting offered by Option & Co has overall much more downsides than upsides compared to union types.
- DougBTX 3y agoThis isn’t just a problem with custom types, it affects generic iteration types too. With a next() -> Option<T> method, an Iterator can iterate over any type of element.
- cubefox 3y agoYeah, but there could be a type T for "any type" additional to union types, basically like TRUE in Boolean logic. (Theoretically you could also have F for "no type", intersection types (AND), negation types (not Foo), and any logical complex of those.)