mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
(cl-type-of): New function to return more precise types (bug#69739)
* src/data.c (Fcl_type_of): New function, extracted from `Ftype_of`. Make it return more precise types for symbols, integers, and subrs. (Ftype_of): Use it. (syms_of_data): Define the corresponding new symbols and defsubr the new function. * doc/lispref/objects.texi (Type Predicates): Document it. * src/comp.c (emit_limple_insn): Use `Fcl_type_of`. * lisp/emacs-lisp/cl-preloaded.el (subr): Demote it to `atom`. (subr-native-elisp, subr-primitive): Add `compiled-function` as parent instead. (special-form): New type. * lisp/obsolete/eieio-core.el (cl--generic-struct-tag): * lisp/emacs-lisp/cl-generic.el (cl--generic-typeof-generalizer): Use `cl-type-of`. cl--generic--unreachable-types): Update accordingly. test/src/data-tests.el (data-tests--cl-type-of): New test.
This commit is contained in:
parent
1a8b34a503
commit
706403f2aa
8 changed files with 108 additions and 17 deletions
|
|
@ -1334,8 +1334,7 @@ These match if the argument is `eql' to VAL."
|
|||
|
||||
(defconst cl--generic--unreachable-types
|
||||
;; FIXME: Try to make that list empty?
|
||||
'(fixnum bignum boolean keyword
|
||||
special-form subr-primitive subr-native-elisp)
|
||||
'(keyword)
|
||||
"Built-in classes on which we cannot dispatch for technical reasons.")
|
||||
|
||||
(defun cl--generic-type-specializers (tag &rest _)
|
||||
|
|
@ -1345,8 +1344,7 @@ These match if the argument is `eql' to VAL."
|
|||
(cl--class-allparents class)))))
|
||||
|
||||
(cl-generic-define-generalizer cl--generic-typeof-generalizer
|
||||
;; FIXME: We could also change `type-of' to return `null' for nil.
|
||||
10 (lambda (name &rest _) `(if ,name (type-of ,name) 'null))
|
||||
10 (lambda (name &rest _) `(cl-type-of ,name))
|
||||
#'cl--generic-type-specializers)
|
||||
|
||||
(cl-defmethod cl-generic-generalizers :extra "typeof" (type)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue