by papsosouid · 13y ago · 0 comments
No, but "is it worse than the very worst possible option" isn't a good standard to use.
>Compared to?
ADTs.
>Why is that?
Because you can use the value even when an error occurred. The type system should prevent this, as is trivially done in every language with ADTs.
In this case, when opening a file, you can go ahead and use the value and "ignore" the error. Go ahead a run either of the above examples. Notice tptacek explicitly ignores the error.
This argument comes up a lot in lieu of or during talk of Generics, so it'd be best for me to defer to those discussions. Unless you or the OP have examples of hating `err` handling not yet described here, opening / reading a file in Go doesn't strike me as a place to take jabs at how errors are handled in Go.