Function: cl-assert
cl-assert is an autoloaded macro defined in cl-macs.el.gz.
Signature
(cl-assert FORM &optional SHOW-ARGS STRING &rest ARGS)
Documentation
Verify that FORM returns non-nil; signal an error if not.
Second arg SHOW-ARGS means to include arguments of FORM in message.
Other args STRING and ARGS... are arguments to be passed to error.
They are not evaluated unless the assertion fails. If STRING is
omitted, a default message listing FORM itself is used.
Aliases
assert (obsolete since 27.1)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-macs.el.gz
;;;###autoload
(defmacro cl-assert (form &optional show-args string &rest args)
;; FIXME: This is actually not compatible with Common-Lisp's `assert'.
"Verify that FORM returns non-nil; signal an error if not.
Second arg SHOW-ARGS means to include arguments of FORM in message.
Other args STRING and ARGS... are arguments to be passed to `error'.
They are not evaluated unless the assertion fails. If STRING is
omitted, a default message listing FORM itself is used."
(declare (debug (form &rest form)))
(and (or (not (macroexp-compiling-p))
(< cl--optimize-speed 3) (= cl--optimize-safety 3))
(let ((sargs (and show-args
(delq nil (mapcar (lambda (x)
(unless (macroexp-const-p x)
x))
(cdr-safe form))))))
`(progn
(or ,form
(cl--assertion-failed
',form ,@(if (or string sargs args)
`(,string (list ,@sargs) (list ,@args)))))
nil))))