LispWorks User Guide and Reference Manual > 7 Dspecs: Tools for Handling Definitions > 7.4 Types of relations between definitions


7.4.1 Functionally equivalent definers

When one definition form simply macroexpands into another, or otherwise has an identical effect as far as the dspec system is concerned, the dspec system should consider them variant forms of the same class.

Use define-dspec-alias to convert one definer to the other during canonicalization. A pre-defined example of this in LispWorks is defparameter and defvar . These cannot be distinguished (other than in the source code), so defparameter has been defined as a dspec alias for defvar . However, defvar and defconstant are distinct kinds of variable, since we can easily tell which type of definition is in effect by calling the function constantp . To define their dspecs, LispWorks creates a dspec class called variable and uses it as the superspace argument when defining the defvar and defconstant dspec classes.

As an explicit example, suppose you have a defining macro

(defmacro parameterdef  (value name)
  `(defparameter ,name ,value))


(dspec:define-dspec-alias parameterdef (value name)
  `(defparameter ,name))

would be a suitable appropriate alias definition. This define-dspec-alias form defines the dspec.

define-dspec-alias is like defmacro for dspecs, so it could be used to describe complicated conversions, as long as it can be done purely statically and totally in terms of existing dspecs. However, nothing more complicated than defparameter has been found necessary.

LispWorks User Guide and Reference Manual - 22 Dec 2009