3 ms·
> If you have multiple things that can fail in sequence, you can "lift" into option and then the result of your expression will either be a real result or a sho
by weberc2 10y ago
> If you have multiple things that can fail in sequence, you can "lift" into option and then the result of your expression will either be a real result or a short-circuited error.
How is that different than with error return values?
> Or just use exceptions. Either would be preferable to C-style error handling.
I disagree. Exceptions seem to hide the problem. In Java and Python, I see people consistently fail to handle exceptions properly. The error paths are neglected because exceptions "hide" them. I would rather have a correct program with verbose error handling than a program that only has an elegant happy path but is otherwise incorrect.
- tiglionabbit 10y ago> How is that different than with error return values? Compare: https://gist.github.com/nickretallack/1462f2652cda6fc2a97283576c379213 https://gist.github.com/nickretallack/1462f2652cda6fc2a97283... If you can find a way to improve these code samples, please suggest it. > Exceptions seem to hide the problem. I haven't used Java in a while, but I recall a feature where it would force you to handle exceptions. It knows what kind of exceptions a function can throw, and it can check if they are exhaustively handled throughout the program.