summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2024-03-12 09:26:24 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2024-03-18 09:29:47 -0400
commit706403f2aa3a306369a0150022da0cba1802ca2b (patch)
treec2a2a7e1dc919efdead6ee36f1fb91e3f624c673 /doc
parent1a8b34a503e5af32851c1aac27a3f09e2345673b (diff)
downloademacs-706403f2aa3a306369a0150022da0cba1802ca2b.tar.gz
(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.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/objects.texi21
1 files changed, 21 insertions, 0 deletions
diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi
index 279f449a994..1e448b64296 100644
--- a/doc/lispref/objects.texi
+++ b/doc/lispref/objects.texi
@@ -2207,6 +2207,27 @@ slot is returned; @ref{Records}.
@end example
@end defun
+@defun cl-type-of object
+This function returns a symbol naming @emph{the} type of
+@var{object}. It usually behaves like @code{type-of}, except
+that it guarantees to return the most precise type possible, which also
+implies that the specific type it returns may change depending on the
+Emacs version. For this reason, as a rule you should never compare its
+return value against some fixed set of types.
+
+@example
+(cl-type-of 1)
+ @result{} fixnum
+@group
+(cl-type-of 'nil)
+ @result{} null
+(cl-type-of (record 'foo))
+ @result{} foo
+@end group
+@end example
+@end defun
+
+
@node Equality Predicates
@section Equality Predicates
@cindex equality