(require :closer-mop) (use-package :closer-mop) (defclass foo () ((one :accessor foo-one :initarg :one :initform 1) (two :accessor foo-two :initarg :two :initform 2)) ) (defclass blah (foo) ()) (defclass bar (blah) ()) (defclass hmm (foo) ()) (defmethod foo-bar ((f foo) (i number)) (+ (foo-one f) i)) (defmethod bar-baz ((b bar) (i number)) (- (foo-two b) i)) (defmethod stuff ((b blah)) nil) (defmethod more-stuff ((h hmm)) nil) (defmethod bad ((i number) (b blah)) nil) (defvar x nil) (setf x (make-instance 'bar)) (print (foo-bar x 4)) (print (bar-baz x 4)) (defun find-methods (class-name) "Return a list of all methods with a given class acceptable as the first argument." (loop for cls in (class-precedence-list (find-class class-name)) until (eql cls (find-class 'standard-object)) append (loop for meth in (specializer-direct-methods cls) if (and (eql (car (method-specializers meth)) cls) (eql (class-of meth) (find-class 'standard-method))) collect meth ) )) (loop for m in (find-methods 'bar) do (print (generic-function-name (method-generic-function m))) )