3 ms·
> With Option types, there is a need for boilerplate unwrapping code in almost every place where you want to use the value. Disagree, in my favorite language y
by kaoD 8y ago
> With Option types, there is a need for boilerplate unwrapping code in almost every place where you want to use the value.
Disagree, in my favorite language you just add "?" to the possibly-erroring function et voilá, error propagated. Even better, since errors are functor-like (map) and monad-like (and_then), I'm mostly never unwrapping myself.
This has the advantage that it's explicit, instead of exceptions implicitly returning early (sometimes to great amusement).
- Faark 8y ago> Disagree, in my favorite language you just add "?" to the possibly-erroring function et voilá, error propagated And one of the first things I had to learn in rust was how make this happen with different error types. After that it was pretty much the same as exceptions. What functions return errors is a little more obvious, at the cost of extra boiler plate (most stuff being Result<...> anyway) Checked exceptions Java style could be a perfect balance with just a few modifications. Compiler/IDE should mostly know whats thrown where, so specifying it manually should rarely be necessary. And still could visualize what can fail and with what errors.