5 ms·
In what cases would that be complicating things? It usually simplifies things. The only cases that I can see where it might complicate things is if your program
by valenterry 2y ago
In what cases would that be complicating things? It usually simplifies things. The only cases that I can see where it might complicate things is if your programming language is too low level or un-ergonomic to properly express or work with sumtypes/uniontypes.
- eru 2y agoWell, Java about 20 years ago would have made this kind of thing really hard. (Or Go about 10 years ago. I don't know if these languages got better in the meantime, I'm just reporting on my experiences from back then.)
- valenterry 2y agoJava today still makes this kind of thing fairly hard actually (well, at least they have some kind of sumtypes and half decent pattern-matching now). Go is even worse.
- freeone3000 2y agoLanguages with sum types, like Haskell and Rust, make these things trivial.
- marcosdumay 2y agoIf you are stuck with Java, you will not want to offload that kind of checking into the static types system. Instead, you have object constructors. Use them. They will dump all kinds of `if (result.is_valid)` variants over your code. But well, this is Java. It's not a different kind of shit from `if (result != null)`, and it's something you have to live with.