- (guard (VAR CLAUSE1 CLAUSE2 ...) BODY )syntax
Syntax: Each clause should have the same form as a cond clause.
Semantics: Whereas raise is analogous to the throw commonly found in other languages, guard is analogous to the try/catch syntax often implemented. VAR gets bound to the exception thrown by BODY, and then the CLAUSEs which have access to VAR, are evaluated until one of the tests succeeds, and the corresponding code gets run. As with cond, the else test always succeeds and so can be used to handle general exceptions.
Notes: guard also supports => in the clauses. If the test returns a useful value, then => can be used to specify a procedure to apply to that value in that case. See the examples section and the srfi for clarification on this.