3 ms·
Given that every single error check there is just passing up the error, is it really that different from having exceptions that propagate along with RAII style
by lclarkmichalek 12y ago
Given that every single error check there is just passing up the error, is it really that different from having exceptions that propagate along with RAII style resource cleanup? The vast vast vast majority of Go code simply propagates errors.
- sagichmal 12y ago> Given that every single error check there is just > passing up the error, is it really that different from > having exceptions that propagate along with RAII style > resource cleanup? Yes, it's fundamentally different. The whole point is to make those error blocks visible, so future maintainers are forced to deal with the reality that those invocations are fallible. Maybe there's a way to make the error handling less verbose, but hiding it altogether would subvert that explicit language design goal.
- lclarkmichalek 12y agoExcept, you know, just mindlessly typing out "if err != nil { return }" does not somehow force enlightenment upon the user. The error blocks are so uniform in their banality that future maintainers treat them the same way that error handling is treated in every other language.
- invisible 12y agoThe fundamental difference is that each separate error is accounted for rather than 4 lines all being treated as error points so you never know which could throw.