The macro
def
informs the system that any definitions within
body
should be recorded as being within the dspec
dspec
. This means that when something attempts to locate such a definition, it should look for a definition named
dspec
.
Use
def
to wrap a group of definitions so that source location for one of the group causes the LispWorks Editor to look for the dspec in the
def
instead. Typically you will also need a define-form-parser definition for the macro that expands into the
def
.
You can also use
def
to provide a dspec for a definition that has its own class that has been defined with define-dspec-class. In this case, you arrange to call record-definition with the same dspec as in the example below.
It is also possible to mix these cases, recording a dspec and also grouping inner definitions. For example
defstruct
does this, recording itself and also grouping definitions such as the constructor function.
In all cases, to make source location work in the LispWorks editor you typically also need a define-form-parser definition for the macro that expands into the
def
.
(defmacro define-wibble (x y)
`(dspec:def (define-wibble ,x)
(set-wibble-definition ',x ',y (dspec:location))))
(defun set-wibble-definition (x y loc)
(when (record-definition `(define-wibble ,x) loc)
;; defining code here
))
LispWorks User Guide and Reference Manual - 21 Dec 2011