Hello!

I want to remove all methods from a generic function which are more
specialized than the classes from an argument list.  With an old CMUCL
(September 2003) the following did work:

  (defun remove-more-specialized-methods (gf template-args)
    "Removes all methods dispatching on subclasses of the template
arguments."
    (loop for method in (copy-seq (pcl::generic-function-methods gf))
          when (every #'subtypep
                      (pcl::method-specializers method)
                      (mapcar #'(lambda (arg)
                                  (if (consp arg)
                                      (second arg)
                                      T))
                              template-args))
          do (remove-method gf method)))

However, I have now installed a newer CMUCL version (from Debian/unstable)
and the above gives errors, because subtypep does not work for PCL classes
which are returned by pcl::method-specializers.  I have a rather ugly
workaround, namely defining something like

(defun method-specializers (method)
  #+cmu (mapcar #'(lambda (class)
                    (etypecase class
                      (pcl::pcl-class (find-class (pcl::class-name class)))
                      (t class)))
                (pcl::method-specializers method))
  #+sbcl (sb-pcl::method-specializers method))

in another package (FL.PORT) and then using this function.  But I suspect
that there is a better way.

Thank you for any information,

Nicolas.

Reply via email to