Mercurial > hg > xemacs-beta
diff lisp/cl-macs.el @ 5263:0d436a78c514
Add an implementation for #'the, cl-macs.el
lisp/ChangeLog addition:
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (the): Add a docstring and an implementation for this
macro.
* bytecomp.el (byte-compile-initial-macro-environment): Add #'the
to this, checking byte-compile-delete-errors to decide whether to
make the type assertion. Change the initvalue to use backquote and
preceding commas for the lambda expressions, to allow the latter
to be compiled.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Thu, 16 Sep 2010 13:36:03 +0100 |
parents | f3eca926258e |
children | f9ec07abdbf9 |
line wrap: on
line diff
--- a/lisp/cl-macs.el Tue Sep 07 17:03:46 2010 +0100 +++ b/lisp/cl-macs.el Thu Sep 16 13:36:03 2010 +0100 @@ -1962,7 +1962,19 @@ ;;;###autoload (defmacro locally (&rest body) (cons 'progn body)) ;;;###autoload -(defmacro the (type form) form) +(defmacro the (type form) + "Assert that FORM gives a result of type TYPE, and return FORM. + +TYPE is a Common Lisp type specifier. + +If macro expansion of a `the' form happens during byte compilation, and the +byte compiler customization variable `byte-compile-delete-errors' is +non-nil, `the' just returns FORM, without making any type checks." + (if (cl-safe-expr-p form) + `(prog1 ,form (assert ,(cl-make-type-test form type) t)) + (let ((saved (gensym))) + `(let ((,saved ,form)) + (prog1 ,saved (assert ,(cl-make-type-test saved type) t)))))) (defvar cl-proclaim-history t) ; for future compilers (defvar cl-declare-stack t) ; for future compilers