Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think that this is sort of cheating. You could have a language that uses "?" as sugar for the more wordy try-catch-return code that you've written here. These examples aren't really showing the semantic difference between errors as values and thrown errors, which is the implicit propagation across multiple code locations.


I love cheating!

> You could have a language that uses "?" as sugar for the more wordy try-catch-return code that you've written here.

I do! (it's ">>=" though, not "?").

> These examples aren't really showing the semantic difference between errors as values and thrown errors, which is the implicit propagation across multiple code locations.

Well here's where we can start to go in circles. I like errors as values, and I dislike Checked Exceptions. But I've seen others argue that Result and Checked Exceptions are completely equivalent. Different people have different ideas about what the semantics are.


True, this might not be the best example, but it shows how much more control and flexibity former approach provides, given rich support fo Result type.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: