Common Lisp the Language 2nd Edition


next up previous contents index
Next: Functions Up: Data Types Previous: Random-States

2.12. Structures

Structures are instances of user-defined data types that have a fixed number of named components. They are analogous to records in Pascal. Structures are declared using the defstruct construct; defstruct automatically defines access and constructor functions for the new data type.

Different structures may print out in different ways; the definition of a structure type may specify a print procedure to use for objects of that type (see the :print-function option to defstruct). The default notation for structures is

#S(structure-name
slot-name-1 slot-value-1
slot-name-2 slot-value-2
...)

where #S indicates structure syntax structure-name is the name (a symbol) of the structure type each slot-name is the name (also a symbol) of a component and each corresponding slot-value is the representation of the Lisp object in that slot.


AI.Repository@cs.cmu.edu