Go: Defer, Panic, and Recover

It seems after much resistance to the idea, Go has added exception handling to the language in the form of defer, panic, and recover.

The Go Programming Language Blog: Defer, Panic, and Recover.

Don’t get me wrong, I think the’ve got something here.  Defer gives you the equivalent of C#’s finally/using; or a nice subset of C++’s destructors; or Lisp’s unwind-protect.  Panic = throw / raise.  Recover = catch.

The blog post gives the impression that you can’t programmatically access the value passed to panic — “recover returns nil” — but before judging that behavior I should try to confirm it in the Go documentation.

All in all, I’m giving this design a thumbs up. No element of it is new, but they seem to have brought exception handling in without compromising their mantra of practical and simple.