catch is used as the destination of a non-local control transfer by throw. Tags are used to find the catch to which a throw is transferring control.
(catch 'foo form
) catches a
(throw 'foo form
) but not a
(throw 'bar form
The order of execution of catch follows:
If during the execution of one of the forms, a throw is executed whose tag is eq to the catch tag, then the values specified by the throw are returned as the result of the dynamically most recently established catch form with that tag.
The mechanism for catch and throw works even if throw is not within the lexical scope of catch. throw must occur within the dynamic extent of the evaluation of the body of a catch with a corresponding tag.
(catch 'dummy-tag 1 2 (throw 'dummy-tag 3) 4)
(catch 'dummy-tag 1 2 3 4)
(catch 'dummy-tag (throw-back 'dummy-tag) 2)
In the below example, we contrast catch behavior with corresponding example of block.