Re:Why Checked Exceptions Failed
by cubefox on Saturday July 15, 2023 @09:52AM
(#36736755)
Something like String|NoAnswer|None doesn't sound too bad to me here...
[ Parent
| on HN ]
This 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.
Yeah, 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.)
Except 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.