comparison 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
comparison
equal deleted inserted replaced
5262:75bcb5bef459 5263:0d436a78c514
1960 ;;; Declarations. 1960 ;;; Declarations.
1961 1961
1962 ;;;###autoload 1962 ;;;###autoload
1963 (defmacro locally (&rest body) (cons 'progn body)) 1963 (defmacro locally (&rest body) (cons 'progn body))
1964 ;;;###autoload 1964 ;;;###autoload
1965 (defmacro the (type form) form) 1965 (defmacro the (type form)
1966 "Assert that FORM gives a result of type TYPE, and return FORM.
1967
1968 TYPE is a Common Lisp type specifier.
1969
1970 If macro expansion of a `the' form happens during byte compilation, and the
1971 byte compiler customization variable `byte-compile-delete-errors' is
1972 non-nil, `the' just returns FORM, without making any type checks."
1973 (if (cl-safe-expr-p form)
1974 `(prog1 ,form (assert ,(cl-make-type-test form type) t))
1975 (let ((saved (gensym)))
1976 `(let ((,saved ,form))
1977 (prog1 ,saved (assert ,(cl-make-type-test saved type) t))))))
1966 1978
1967 (defvar cl-proclaim-history t) ; for future compilers 1979 (defvar cl-proclaim-history t) ; for future compilers
1968 (defvar cl-declare-stack t) ; for future compilers 1980 (defvar cl-declare-stack t) ; for future compilers
1969 1981
1970 (defun cl-do-proclaim (spec hist) 1982 (defun cl-do-proclaim (spec hist)