3 ms·
Go backed into exceptions. Originally, "panic" was always fatal.[1] Then came "recover".[2] But it was considered bad form to use "recover" for anything other t
by Animats 10y ago
Go backed into exceptions. Originally, "panic" was always fatal.[1]
Then came "recover".[2] But it was considered bad form to use "recover" for anything other than doing a final cleanup and exit. Now, the library JSON parser can panic and recover due to invalid input, then return an error code. That's exception handling.
Now we have to give up optimizations so that Go's exception handling will work. Every function call, every subscripted access, and every map reference is a potential loop exit. Bleah.
[1] http://dave.cheney.net/2012/01/18/why-go-gets-exceptions-right http://dave.cheney.net/2012/01/18/why-go-gets-exceptions-rig...
[2] https://groups.google.com/forum/#!topic/golang-nuts/HOXNBQu5c-Q%5B1-25%5D https://groups.google.com/forum/#!topic/golang-nuts/HOXNBQu5...