Commit fb997d30 authored by Stefan Monnier's avatar Stefan Monnier

* lisp/emacs-lisp/cl-generic.el (cl--generic-typeof-types): Add `atom'

remove entries whose car can't be returned by type-of.
(cl--generic-all-builtin-types): New var.
(cl-generic-generalizers): Use it to avoid requiring
extra entries in cl--generic-typeof-types.
parent 907bad07
......@@ -1144,21 +1144,28 @@ These match if the argument is `eql' to VAL."
(defconst cl--generic-typeof-types
;; Hand made from the source code of `type-of'.
'((integer number) (symbol) (string array sequence) (cons list sequence)
'((integer number number-or-marker atom)
(symbol atom) (string array sequence atom)
(cons list sequence)
;; Markers aren't `numberp', yet they are accepted wherever integers are
;; accepted, pretty much.
(marker) (overlay) (float number) (window-configuration)
(process) (window) (subr) (compiled-function) (buffer)
(char-table array sequence)
(bool-vector array sequence)
(frame) (hash-table) (font-spec) (font-entity) (font-object)
(vector array sequence)
;; Plus, hand made:
(null symbol list sequence)
(list sequence)
(array sequence)
(marker number-or-marker atom)
(overlay atom) (float number atom) (window-configuration atom)
(process atom) (window atom) (subr atom) (compiled-function function atom)
(buffer atom) (char-table array sequence atom)
(bool-vector array sequence atom)
(frame atom) (hash-table atom)
(font-spec atom) (font-entity atom) (font-object atom)
(vector array sequence atom)
;; Plus, really hand made:
(null symbol list sequence atom))
"Alist of supertypes.
Each element has the form (TYPE . SUPERTYPES) where TYPE is one of
the symbols returned by `type-of', and SUPERTYPES is the list of its
supertypes from the most specific to least specific.")
(defconst cl--generic-all-builtin-types
(delete-dups (copy-sequence (apply #'append cl--generic-typeof-types))))
(cl-generic-define-generalizer cl--generic-typeof-generalizer
;; FIXME: We could also change `type-of' to return `null' for nil.
......@@ -1170,9 +1177,9 @@ These match if the argument is `eql' to VAL."
"Support for dispatch on builtin types.
See the full list and their hierarchy in `cl--generic-typeof-types'."
;; FIXME: Add support for other types accepted by `cl-typep' such
;; as `character', `atom', `face', `function', ...
;; as `character', `face', `function', ...
(and (assq type cl--generic-typeof-types)
(and (memq type cl--generic-all-builtin-types)
;; FIXME: While this wrinkle in the semantics can be occasionally
;; problematic, this warning is more often annoying than helpful.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment