Next: Quasiquotation, Previous: Dynamic bindings, Up: Derived expression types [Index]
(guard (⟨variable⟩ ⟨cond clause1⟩ ⟨cond clause2⟩ …)⟨body⟩)
Syntax: Each ⟨cond clause⟩ is as in the specification of cond.
Semantics: The ⟨body⟩ is evaluated with an exception
handler that binds the raised object (see raise in Exceptions)
to ⟨variable⟩ 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
⟨cond clause⟩’s ⟨test⟩ evaluates to #f and there
is no else clause, then
raise-continuable is invoked on the raised object within the dynamic
environment of the original call to raise
or raise-continuable, except that the current
exception handler is that of the guard expression.
See Exceptions for a more complete discussion of exceptions.
(guard (condition
((assq 'a condition) => cdr)
((assq 'b condition)))
(raise (list (cons 'a 42))))
⇒ 42
(guard (condition
((assq 'a condition) => cdr)
((assq 'b condition)))
(raise (list (cons 'b 23))))
⇒ (b . 23)