Find all methods that specialize in a given type.

Is there a way to find all functions that specialize in a given type?

I predict that you could execute from repl as (find-all-specializing-methods 'my-class) and it will return a list of methods like (mypackage1:my-method-1 my-package2:my-method-2 etc.)

I think there should be an easy way to do this, because the MOP itself should probably keep such a list in order to decide which methods to call.

+6
source share
1 answer

To find out what you can take a look at slime-who-specializes and find out how to do this for your installation.

Following the definitions, I got so far (for SBCL):

 #+#.(swank-backend::sbcl-with-xref-p) (progn (defmacro defxref (name &optional fn-name) `(defimplementation ,name (what) (sanitize-xrefs (mapcar #'source-location-for-xref-data (,(find-symbol (symbol-name (if fn-name fn-name name)) "SB-INTROSPECT") what))))) (defxref who-calls) (defxref who-binds) (defxref who-sets) (defxref who-references) (defxref who-macroexpands) #+#.(swank-backend:with-symbol 'who-specializes-directly 'sb-introspect) (defxref who-specializes who-specializes-directly)) 

This functionality is implemented separately for different Lisp, so if you need specific details, you will need to study: swank-<your lisp>.lisp file and search for the common who-specializes function.

+5
source

All Articles