Mercurial > hg > xemacs-beta
diff lisp/cl-extra.el @ 5056:6aba0daedb7c
Add #'constantly, as specified by ANSI Common Lisp.
2010-02-22 Aidan Kehoe <kehoea@parhasard.net>
* cl-extra.el (constantly):
Add this function, from ANSI Common Lisp, using the SBCL extension
that extra arguments to it are passed back as multiple values in
the constructed function.
* cl-macs.el (constantly):
In the compiler macro for #'constantly, construct a
compiled-function object almost every time, at compile time when
all arguments are constant, and at runtime when they vary.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 22 Feb 2010 20:08:51 +0000 |
parents | 8800b5350a13 |
children | 868a9ffcc37b |
line wrap: on
line diff
--- a/lisp/cl-extra.el Fri Feb 19 23:46:53 2010 +0000 +++ b/lisp/cl-extra.el Mon Feb 22 20:08:51 2010 +0000 @@ -612,6 +612,17 @@ ((memq (car plst) indicator-list) (return (values (car plst) (cadr plst) plst)))))) +;; See our compiler macro in cl-macs.el, we will only pass back the +;; actual lambda list in interpreted code or if we've been funcalled +;; (from #'apply or #'mapcar or whatever). +(defun constantly (value &rest more-values) + "Construct a function always returning VALUE, and possibly MORE-VALUES. + +The constructed function accepts any number of arguments, and ignores them. + +Members of MORE-VALUES, if provided, will be passed as multiple values; see +`multiple-value-bind' and `multiple-value-setq'." + `(lambda (&rest ignore) (values-list ',(cons value more-values)))) ;;; Hash tables.