Function: cl-block
cl-block is an autoloaded macro defined in cl-macs.el.gz.
Signature
(cl-block NAME &rest BODY)
Documentation
Define a lexically-scoped block named NAME.
NAME may be any symbol. Code inside the BODY forms can call cl-return-from
to jump prematurely out of the block. This differs from catch and throw
in two respects: First, the NAME is an unevaluated symbol rather than a
quoted symbol or other form; and second, NAME is lexically rather than
dynamically scoped: Only references to it within BODY will work. These
references may appear inside macro expansions, but not inside functions
called from BODY.
Aliases
block (obsolete since 27.1)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-macs.el.gz
;;; Blocks and exits.
;;;###autoload
(defmacro cl-block (name &rest body)
"Define a lexically-scoped block named NAME.
NAME may be any symbol. Code inside the BODY forms can call `cl-return-from'
to jump prematurely out of the block. This differs from `catch' and `throw'
in two respects: First, the NAME is an unevaluated symbol rather than a
quoted symbol or other form; and second, NAME is lexically rather than
dynamically scoped: Only references to it within BODY will work. These
references may appear inside macro expansions, but not inside functions
called from BODY."
(declare (indent 1) (debug (symbolp body)))
(if (cl--safe-expr-p `(progn ,@body)) `(progn ,@body)
`(cl--block-wrapper
(catch ',(intern (format "--cl-block-%s--" name))
,@body))))