(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.
This commit is contained in:
Stefan Monnier 2024-03-17 17:29:02 -04:00
parent 706403f2aa
commit e624bc6275
5 changed files with 18 additions and 7 deletions

View file

@ -436,7 +436,7 @@ For this build of Emacs it's %dbit."
"Type of the core syntactic elements of the Emacs Lisp language.")
(cl--define-built-in-type subr-native-elisp (subr compiled-function)
"Type of functions that have been compiled by the native compiler.")
(cl--define-built-in-type subr-primitive (subr compiled-function)
(cl--define-built-in-type primitive-function (subr compiled-function)
"Type of functions hand written in C.")
(unless (cl--class-parents (cl--find-class 'cl-structure-object))