4 ms·
I don’t remember! Possibly that’s one of the cases where it doesn’t work out. Of course, if you had proper sum types, that situation wouldn’t be a problem.
by iainmerrick 2y ago
I don’t remember! Possibly that’s one of the cases where it doesn’t work out.
Of course, if you had proper sum types, that situation wouldn’t be a problem.
- gf000 2y agoJava has proper sum types, but what one needs here is union types. They are not the same, sum types are labeled and are disjoint. You want `MyException | ThirdPartyException` here, though.
- iainmerrick 2y agoYou're right, I had it backwards! Thanks for the correction. Now I'm wondering, could that actually be all that's needed to rescue checked exceptions? Is there any language that has that combination of features?
- gf000 2y agoWell, scala has union types, but it doesn't do checked exceptions per say (but it does have a very advanced type system so similar structure can be easily encoded). I think checked exceptions is pretty rare, so I don't know.. probably some research language (but they often go the extra mile towards effect types)
- int_19h 2y agoBack when Java didn't have lambdas, one of the more advanced lambda proposals (http://www.javac.info/closures-v06a.html http://www.javac.info/closures-v06a.html) had this exact thing for this exact reason. Unfortunately, this take on lambdas was deemed too complicated, and so we got the present system which doesn't really try to deal with this use case at all.