Comment by drysine
5 hours ago
As a matter of fact I did when it appeared on hn.
>forces you to handle it.
By writing `?`) And we get poor man's exceptions.
5 hours ago
As a matter of fact I did when it appeared on hn.
>forces you to handle it.
By writing `?`) And we get poor man's exceptions.
Poor man's checked exceptions. That's important. From the `?` you always see which functions can fail and cause an early return. You can confidently refactor and use local reasoning based on the function signature. The compiler catches your mistakes when you call a fallible function from a supposedly infallible function, and so on. Unchecked exceptions don't give you any of that. Java's checked exceptions get close and you can use `throws Exception` very similarly to `anyhow::Result`. But Java doesn't allow you to be generic over checked exceptions (as discussed in the post). This is a big hurdle that makes Result superior.