guard[syntax] guard (var clause1 clause2 ...) body ...
SRFI-34:
Each clause should have the same form as a cond clause.
Evaluating a guard form evaluates body with an exception handler that binds
the raised object to var and within the scope of that binding evaluates the clauses as
if they were the clauses of a cond expression. That implicit cond expression is evaluated
with the continuation and dynamic environment of the guard expression.
If every clause's test evaluates to false and there is no else clause,
then raise is re-invoked on the raised object within the dynamic environment of the
original call to raise except that the current exception handler is that of the guard expression.
(guard (condition
((assq 'a condition) => cdr)
((assq 'b condition)))
(raise (list (cons 'a 42))))
See also with-exception-handler, raise.
|