DEV Community

Discussion on: More on error handling in C3

Collapse
 
lerno profile image
Christoffer Lernö

There are some possibilities if one wants to guard against forgotten errors - and those are similar to Go:

  1. Require a function to store a failable in a variable, or assign it to “nothing” (_ in Go)
  2. Together with the above, require use of said variable unless it is the “nothing” variable.
  3. One can go even further requiring it is either used in a call chain or passed to either try or catch.

The above may be set as simply warnings or notices.

And yes, a function returning void! can be invoked on a line by itself.

defer, defer catch and defer try will invoke on any, error and normal return respectively.

The error is likely to be available in the catch version of the defer.

It is an interesting idea to unify them. I’ll give it some thought.