Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.


XLISP provides a subset of the Common Lisp structure definition facility. No options or slot options are allowed, but slots can have default initialization expressions.

(defstruct name <slot-desc>...)
(defstruct (name <option>...) <slot-desc>...)
    <name>      the structure name symbol
    <option>    option description
    <slot-desc> slot descriptions
    returns     the structure name

The recognized options are:

        (:conc-name name)
        (:include name [<slot-desc>...])

Note that if :CONC-NAME appears, it should be before :INCLUDE.

Each slot description takes the form:

        (<name> <defexpr>)

If the default initialization expression is not specified, the slot will be initialized to NIL if no keyword argument is passed to the creation function.

DEFSTRUCT causes access functions to be created for each of the slots and also arranges that SETF will work with those access functions. The access function names are constructed by taking the structure name, appending a '-' and then appending the slot name. This can be overridden by using the :CONC-NAME option.

DEFSTRUCT also makes a creation function called MAKE- <structname>, a copy function called COPY-<structname> and a predicate function called <structname>-P. The creation function takes keyword arguments for each of the slots.

For instance:

        (defstruct foo bar (gag 2))

creates the following functions:

        (foo-bar <expr>)
        (setf (foo-bar <expr>) <value>)
        (foo-gag <expr>)
        (setf (foo-gag <expr>) <value>)
        (make-foo &key :bar :gag)
        (copy-foo <expr>)
        (foo-p <expr>)

Go to the first, previous, next, last section, table of contents.