Exceptions
==========
It is traditional in Scheme to implement exception systems using
`call-with-current-continuation'. Guile does not do this, for
performance reasons. The implementation of
`call-with-current-continuation' is a stack copying implementation.
This allows it to interact well with ordinary C code. Unfortunately, a
stack-copying implementation can be slow - creating a new continuation
involves a block copy of the stack.
Instead of using `call-with-current-continuation', the exception
primitives documented here are implemented as built-ins that take
advantage of the _upward only_ nature of exceptions.
- primitive: catch tag thunk handler
Invoke THUNK in the dynamic context of HANDLER for exceptions
matching KEY. If thunk throws to the symbol KEY, then HANDLER is
invoked this way:
(handler key args ...)
KEY is a symbol or #t.
THUNK takes no arguments. If THUNK returns normally, that is the
return value of `catch'.
Handler is invoked outside the scope of its own `catch'. If
HANDLER again throws to the same key, a new handler from further
up the call chain is invoked.
If the key is `#t', then a throw to _any_ symbol will match this
call to `catch'.
- primitive: throw key . args
Invoke the catch form matching KEY, passing ARGS to the HANDLER.
KEY is a symbol. It will match catches of the same symbol or of
#t.
If there is no handler at all, an error is signaled.
- primitive: lazy-catch tag thunk handler