changeset 93735:310118b32104

(functionp): Return nil for special forms.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 05 Apr 2008 20:22:22 +0000
parents 0a5160e7009f
children 1014806714ab
files doc/lispref/functions.texi etc/NEWS lisp/ChangeLog lisp/subr.el
diffstat 4 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/doc/lispref/functions.texi	Sat Apr 05 20:21:48 2008 +0000
+++ b/doc/lispref/functions.texi	Sat Apr 05 20:22:22 2008 +0000
@@ -116,9 +116,7 @@
 
 @defun functionp object
 This function returns @code{t} if @var{object} is any kind of
-function, or a special form, or, recursively, a symbol whose function
-definition is a function or special form.  (This does not include
-macros.)
+function, i.e. can be passed to @code{funcall}.
 @end defun
 
 Unlike @code{functionp}, the next three functions do @emph{not}
--- a/etc/NEWS	Sat Apr 05 20:21:48 2008 +0000
+++ b/etc/NEWS	Sat Apr 05 20:22:22 2008 +0000
@@ -654,6 +654,9 @@
 
 * Incompatible Lisp Changes in Emacs 23.1
 
+** `functionp' returns nil for special forms.
+I.e. it only returns t for objects that can be passed `funcall'.
+
 +++
 ** The multibyteness of process filters is determined by the coding-system
 used for decoding.  The functions `process-filter-multibyte-p' and
--- a/lisp/ChangeLog	Sat Apr 05 20:21:48 2008 +0000
+++ b/lisp/ChangeLog	Sat Apr 05 20:22:22 2008 +0000
@@ -1,3 +1,7 @@
+2008-04-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* subr.el (functionp): Return nil for special forms.
+
 2008-04-05  Glenn Morris  <rgm@gnu.org>
 
 	* emacs-lisp/autoload.el (autoload-ensure-default-file):
--- a/lisp/subr.el	Sat Apr 05 20:21:48 2008 +0000
+++ b/lisp/subr.el	Sat Apr 05 20:22:22 2008 +0000
@@ -231,17 +231,17 @@
        (eq (car object) 'frame-configuration)))
 
 (defun functionp (object)
-  "Non-nil if OBJECT is any kind of function or a special form.
-Also non-nil if OBJECT is a symbol and its function definition is
-\(recursively) a function or special form.  This does not include
-macros."
+  "Non-nil if OBJECT is a function."
   (or (and (symbolp object) (fboundp object)
 	   (condition-case nil
 	       (setq object (indirect-function object))
 	     (error nil))
 	   (eq (car-safe object) 'autoload)
 	   (not (car-safe (cdr-safe (cdr-safe (cdr-safe (cdr-safe object)))))))
-      (subrp object) (byte-code-function-p object)
+      (and (subrp object)
+           ;; Filter out special forms.
+           (not (eq 'unevalled (cdr (subr-arity object)))))
+      (byte-code-function-p object)
       (eq (car-safe object) 'lambda)))
 
 ;;;; List functions.