Blocks and Exits



block tag {form}* [special]
makes a lexical block from which you can exit by return-from. Tag is lexically scoped and is not evaluated.


return-from tag value [special]

exits the block labeled by tag. return-from can be used to exit from a function or a method which automatically establishes block labeled by its function or method name surrounding the entire body.


return value [macro]

(return x) is equivalent to (return-from nil x). This is convenient to use in conjunction with loop, while, do, dolist, and dotimes which implicitly establish blocks labeled NIL.


catch tag {form}* [special]

establishes a dynamic block from which you can exit and return a value by throw. Tag is evaluated. The list of all visible catch tags can be obtained by sys:list-all-catchers.


throw tag value [special]

exits and returns value from a catch block. tag and value are evaluated.


unwind-protect protected-form {cleanup-form}* [special]

After the evaluation of protected-form finishes, cleanup-form is evaluated. You may make a block or a catch block outside the unwind-protect. Even return-from or throw is executed in protected-form to escape from such blocks, cleanup-form is assured to be evaluated. Also, if you had an error while executing protected-form, cleanup-form would always be executed by reset.


k-okada 2013-05-21