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


Subject: Re: Is there an example of a function that will
>    return ALL subclasses of a given class, not just the direct subclasses?
>    I am looking for a recursive version of class-direct-subclasses that will
>    return all the classes in a list, and I'm (for the moment) too lazy to
>    write such a beast.....
(defun find-all-subclasses (class &aux so-far)
  "recursively finds all the subclasses of class, without duplicates"
  (when class
    (let ((new-subclasses
           (set-difference (class-direct-subclasses class) so-far)))
      (setf so-far (append new-subclasses so-far))
      (dolist (class new-subclasses)
        (setf so-far (find-subclasses class so-far)))))
;eg (find-all-subclasses (find-class 'stream))