lisp-random / class-checking.lisp

Robert Smith d2d7efd 

(defun gf-specializers (gf &key names?)
  (mapcar (lambda (m)
            (mapcar (if names?
                        #'identity) (sb-mop:method-specializers m)))
          (sb-mop:generic-function-methods gf)))

(defun gf-specializers-nth (n gf &key names?)
  (mapcar (lambda (l) (nth n l)) (gf-specializers gf :names? names?)))

(defun class-subclasses-aux (class)
   (let ((subclasses (sb-mop:class-direct-subclasses class)))
     (when (car subclasses)
       (cons subclasses
             (let ((subsubclasses (mapcar #'class-subclasses subclasses)))
               (when (car subsubclasses)

(defun class-subclasses (class &key names?)
  "All descendents/subclasses of CLASS."
  (if names?
      (mapcar #'class-name (class-subclasses-aux class))
      (class-subclasses-aux class)))

;;; This function is not quite right because given class C with
;;; subclass K, if GF specializes for C, but doesn't directly
;;; specialize for K, it's not an issue. This function, however, will
;;; return NIL in such a case since the subclass hierarchy is
;;; basically ignored.
(defun gf-specializes-all-subclasses-of (class gf &key (argument 0))
  "Does the generic function GF specialize all subclasses of CLASS?"
  (subsetp (class-subclasses class :names? t)
           (gf-specializers-nth argument gf :names? t) :test #'equal))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.