Skip to content

Instantly share code, notes, and snippets.

@imagescape
Created November 1, 2012 18:00
Show Gist options
  • Save imagescape/3995405 to your computer and use it in GitHub Desktop.
Save imagescape/3995405 to your computer and use it in GitHub Desktop.
let b = do OutOfKittens.protect {
do_some_stuff();
that_might_raise();
out_of_kittens();
};
do b.handle |t| {
UseAardvarksInstead
}
# vs
let p = do Protect {
do_some_stuff();
that_might_raise();
anything_really();
};
do p.handle(OutOfKittens) |t| {
UseAardvarksInstead();
}
do p.handle(OtherException) |t| {
WriteDumpInfo();
}
# vs
let p = do Protect {
... closure
};
match p {
OutOfKittens => UseAardvarksInstead();
OtherException => WriteDumpInfo();
_ => # failure
}
@bstrie
Copy link

bstrie commented Nov 1, 2012

At what point does the protected closure get evaluated? Are you intending to run it twice, or is this supposed to be a demonstration of attaching multiple handlers to a single piece of code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment