summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2024-03-17 17:29:02 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2024-03-18 09:32:49 -0400
commite624bc62752ceb2e60940c5fd9cb6e70611df71c (patch)
tree43890e0601aacb600479590fb52ba5440e4fca91 /lisp/subr.el
parent706403f2aa3a306369a0150022da0cba1802ca2b (diff)
downloademacs-e624bc62752ceb2e60940c5fd9cb6e70611df71c.tar.gz
(primitive-function): New type
The type hierarchy and `cl-type-of` code assumed that `subr-primitive` only applies to functions, but since it also accepts special-forms it makes it an unsuitable choice since it can't be a subtype of `compiled-function`. So, use a new type `primitive-function` instead. * lisp/subr.el (subr-primitive-p): Fix docstring (bug#69832). (primitive-function-p): New function. * lisp/emacs-lisp/cl-preloaded.el (primitive-function): Rename from `subr-primitive` since `subr-primitive-p` means something else. * src/data.c (Fcl_type_of): Return `primitive-function` instead of `subr-primitive` for C functions. (syms_of_data): Adjust accordingly. * test/src/data-tests.el (data-tests--cl-type-of): Remove workaround.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el11
1 files changed, 10 insertions, 1 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 38a3f6edb34..3de4412637f 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -312,11 +312,20 @@ value of last one, or nil if there are none."
cond '(empty-body unless) t)))
(defsubst subr-primitive-p (object)
- "Return t if OBJECT is a built-in primitive function."
+ "Return t if OBJECT is a built-in primitive written in C.
+Such objects can be functions or special forms."
(declare (side-effect-free error-free))
(and (subrp object)
(not (subr-native-elisp-p object))))
+(defsubst primitive-function-p (object)
+ "Return t if OBJECT is a built-in primitive function.
+This excludes special forms, since they are not functions."
+ (declare (side-effect-free error-free))
+ (and (subrp object)
+ (not (or (subr-native-elisp-p object)
+ (eq (cdr (subr-arity object)) 'unevalled)))))
+
(defsubst xor (cond1 cond2)
"Return the boolean exclusive-or of COND1 and COND2.
If only one of the arguments is non-nil, return it; otherwise