Skip to content

Instantly share code, notes, and snippets.

View spakin's full-sized avatar

Scott Pakin spakin

View GitHub Profile
@spakin
spakin / returnfrom.md
Last active April 1, 2019 17:15
Go 2 error handling based on non-local returns

Summary

Although in Error Handling — Problem Overview, Russ Cox does a great job motivating the need for lighter-weight error handling, I have a few concerns with the catch and handle mechanisms proposed for Go2. I most dislike the fact that only one handler can be active at any point in the code. I largely disapprove of recoverable errors not being supported. And I'm not particularly fond of check being hard-wired to work only with type error.

In my counter-proposal, I call for a single new keyword, returnfrom:

ReturnFromStmt = "returnfrom" Label [ExpressionList] .

The semantics is that returnfrom behaves like a return appearing in the same scope as a given label. It's therefore a bit like a goto but supports the handler nesting that Cox's article calls out as important for proper cleanup.

@spakin
spakin / keybase.md
Created January 9, 2015 07:21
Proving my GitHub identity to Keybase

Keybase proof

I hereby claim:

  • I am spakin on github.
  • I am pakin (https://keybase.io/pakin) on keybase.
  • I have a public key whose fingerprint is 888E 96CC B15F 8E47 6D4A 1F45 6F7F 752C CCA3 F9F5

To claim this, I am signing this object: