3 ms·
Let's imagine a syntax-sugared Go... Every function has a hidden "err" return value Every function has an "exceptionExit:" block, by default it does just "ret
by lucio 8y ago
Let's imagine a syntax-sugared Go...
Every function has a hidden "err" return value
Every function has an "exceptionExit:" block, by default it does just "return err;"
After every function call, an automatic
"if err != nil {goto exceptionExit}" is added.
You can add an "exception" block to a function, it replaces the default.
Now you have function level exceptions in Go just by syntax sugar, without stack unwinding and without requiring new compiler functionality, just syntax sugar.