emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master fb997d3: * lisp/emacs-lisp/cl-generic.el (cl--gener


From: Stefan Monnier
Subject: [Emacs-diffs] master fb997d3: * lisp/emacs-lisp/cl-generic.el (cl--generic-typeof-types): Add `atom'
Date: Tue, 21 Feb 2017 21:47:29 -0500 (EST)

branch: master
commit fb997d30af28da4712ca64876feddbd07db20e13
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * 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.
---
 lisp/emacs-lisp/cl-generic.el | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index b7695af..8517e1e 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -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)
-    (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.
@@ -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', ...
   (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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]