NextPrevUpTopContentsIndex

def

Macro
Summary

Informs the system of a name for a definition.

Package

dspec

Signature

def dspec &body body => result

Arguments

dspec

A dspec.

body

Lisp forms, evaluated as an implicit progn .

Values

result

The result of body .

Description

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 .

dspec can be non-canonical.

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 .

Example
(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
    ))
See also

location


LispWorks Reference Manual - 12 Mar 2008

NextPrevUpTopContentsIndex