atomo-0.4: prelude/exception.atomo
macro (action handle: (branches: Block))
{ handlers = branches contents map:
{ `(~c -> ~e) | `(~c -> !escape-handle yield: ~e)
}
`({ !escape-handle | ~action bind: ~(`Block new: handlers) } call/cc)
} call
macro (a handle: (b: Block) ensuring: (c: Block))
`({ ~a handle: ~b } ensuring: ~c)
(action: Block) catch: recover :=
{ cc |
action bind: {
Error -> { e | cc yield: (recover call: e) }
}
} call/cc
macro (a catch: (b: Block) ensuring: (c: Block))
`({ ~a catch: ~b } ensuring: ~c)
(action: Block) ensuring: (cleanup: Block) :=
action after: cleanup
v ensuring: p do: b :=
{ b call: v } ensuring: { p call: v }