Next: , Previous: , Up: SRFI Support   [Contents][Index]


7.5.23 SRFI-34 - Exception handling for programs

Guile provides an implementation of SRFI-34’s exception handling mechanisms as an alternative to its own built-in mechanisms (see Exceptions). It can be made available as follows:

(use-modules (srfi srfi-34))

See Raising and Handling Exceptions, for more on with-exception-handler and raise (known as raise-exception in core Guile).

SRFI-34’s guard form is syntactic sugar over with-exception-handler:

Syntax: guard (var clause …) body …

Evaluate body with an exception handler that binds the raised object to var and within the scope of that binding evaluates clause… 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.