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

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.....

This is faster and conses less then Jonathan Pierce's example.
It's also less general.

(defun class-all-subclasses (class)
  (labels ((foo (class res)
             (unless (member class res)
               (push class res)
               (dolist (subclass (class-direct-subclasses class))
                 (setq res (foo subclass res))))
             res))
    (foo class nil)))