3 ms·
> Go's pragmatic decision not to have exceptions Um, what problems do exceptions introduce that panics don't?
by catnaroek 11y ago
> Go's pragmatic decision not to have exceptions
Um, what problems do exceptions introduce that panics don't?
- stcredzero 11y agoNone, but here's the thing about pragmatic design: You just have to make something that's less problematic the common case.
- catnaroek 11y agoExceptions are meant to be used for exceptional situations too. (Heck, the intended use is in the name!) Using them for normal control flow is bad programming style. (I'm looking at you, Python!) In any case, the argument in favor of using return values for handling error conditions would be stronger if Go had proper tagged unions. With tagged unions, you can guarantee that exactly one of an OK result of an error object will be returned. Right now, Go has the very confusing situation that a function might return two `nil`s (the operation neither succeeded nor failed) or two non-`nil`s (the operation both succeeded and failed), neither of which makes any sense.