DEV Community

Discussion on: Go 2 Draft: Error Handling

Collapse
 
dean profile image
dean • Edited

Implicit error checking is just kinda... bad. As a quote from the draft -

The subtleties of implicit checking are covered well in Raymond Chen’s pair of blog posts, “Cleaner, more elegant, and wrong” (2004), and “Cleaner, more elegant, and harder to recognize” (2005). In essence, because you can’t see implicit checks at all, it is very hard to verify by inspection that the error handling code correctly recovers from the state of the program at the time the check fails.

In terms of that reaction, I actually like that. Once a handle leaves scope, it should no longer be used.
I also think that defer should work the same way. A defer should execute when it leaves its scope, not when the function is done executing. It just makes more sense in my eyes and is much more intuitive.

For the syntax highlighting, I used a capital "G" on accident, I'll fix that!

Collapse
 
rhymes profile image
rhymes

Implicit error checking is just kinda... bad. As a quote from the draft

I meant, implicit usage of check (you can derive which functions need a check if one of the return values is error) but still with explicit error handling.

But now, while writing this, I think I understood. If they remove the explicit check there's no way for the programmer to instantly figure out which method calls can trigger an error, unless they inspect the source code.

Using check also allows the compiler to throw errors if someone forgot to add check.