3 ms·
Rust's Result type is isomorphic with checked exceptions, FWIW, just a bit more explicit in its use.
by barrkel 8y ago
Rust's Result type is isomorphic with checked exceptions, FWIW, just a bit more explicit in its use.
- int_19h 8y agoIt's also more flexible and composable, since checked exceptions aren't quite a proper part of the type system. Consider the case of a higher-order function that wants to derive its exception specification from the function it wraps.
- barrkel 8y agoEh. Very easy to model as a second return type on the function type. If your function type is polymorphic, it's just another type argument.
- int_19h 8y agoYou also need union types. But yes, you can make it work (the original lambda proposal for Java tried to do that). Of course, once you push it to the point where it does, then it is practically indistinguishable from having a single return value that is a discriminated union.