(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)
- (sequence)
- (number)))
+ (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.
"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', ...
(or
- (and (assq type cl--generic-typeof-types)
+ (and (memq type cl--generic-all-builtin-types)
(progn
;; FIXME: While this wrinkle in the semantics can be occasionally
;; problematic, this warning is more often annoying than helpful.