All Manuals > LispWorks User Guide and Reference Manual > 7 Dspecs: Tools for Handling Definitions > 7.9 Users of location information


7.9.6 Example: my-defmethod

Suppose you have a method definer my-defmethod :

(defmacro my-defmethod ((name &key doc)
                         &body body)
  `(defmethod ,name ,lambda-list ,@body))

Unlike function dspecs, method dspecs need to include the specialized argument types as well as the function name, so the alias and the parser both need to be more complex.

This causes the dspec to include the argument types:

(dspec:define-dspec-alias my-defmethod (name &rest options)
  `(defmethod ,name ,@options))

The dspec parser for method lambda lists is complicated, but you can invoke the defmethod parser in your my-defmethod parser, like this:

(dspec:define-form-parser my-defmethod (name-stuff lambda-list)
  `(,my-defmethod ,@(cdr (dspec:parse-form-dspec
                          `(defmethod ,(car name-stuff)

Now this definition can be located:

(my-defmethod (bar :doc "bar documentation") (x y)
  (foo x y))

just as if it were:

(defmethod bar (x y)
  (foo x y))

LispWorks User Guide and Reference Manual - 21 Dec 2011