48 lines
2.3 KiB
HTML
48 lines
2.3 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
|
||
|
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
|
||
|
<HEAD>
|
||
|
<TITLE>2.12. Structures</TITLE>
|
||
|
</HEAD>
|
||
|
<BODY>
|
||
|
<meta name="description" value=" Structures">
|
||
|
<meta name="keywords" value="clm">
|
||
|
<meta name="resource-type" value="document">
|
||
|
<meta name="distribution" value="global">
|
||
|
<P>
|
||
|
<b>Common Lisp the Language, 2nd Edition</b>
|
||
|
<BR> <HR><A NAME=tex2html1987 HREF="node40.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html1985 HREF="node15.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html1979 HREF="node38.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html1989 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html1990 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
||
|
<B> Next:</B> <A NAME=tex2html1988 HREF="node40.html"> Functions</A>
|
||
|
<B>Up:</B> <A NAME=tex2html1986 HREF="node15.html"> Data Types</A>
|
||
|
<B> Previous:</B> <A NAME=tex2html1980 HREF="node38.html"> Random-States</A>
|
||
|
<HR> <P>
|
||
|
<H1><A NAME=SECTION006120000000000000000>2.12. Structures</A></H1>
|
||
|
<P>
|
||
|
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 <tt>defstruct</tt> construct;
|
||
|
<tt>defstruct</tt> automatically defines access and constructor functions for
|
||
|
the new data type.
|
||
|
<P>
|
||
|
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
|
||
|
<tt>:print-function</tt> option to <tt>defstruct</tt>).
|
||
|
The default notation for structures is
|
||
|
<P><pre>
|
||
|
#S(<i>structure-name</i>
|
||
|
<i>slot-name-1</i> <i>slot-value-1</i>
|
||
|
<i>slot-name-2</i> <i>slot-value-2</i>
|
||
|
...)
|
||
|
</pre><P>
|
||
|
where <tt>#S</tt> indicates structure syntax, <i>structure-name</i> is
|
||
|
the name (a symbol) of the structure type, each <i>slot-name</i> is the name
|
||
|
(also a symbol) of a component, and each corresponding <i>slot-value</i>
|
||
|
is the representation of the Lisp object in that slot.
|
||
|
<P>
|
||
|
<HR>
|
||
|
<P><ADDRESS>
|
||
|
AI.Repository@cs.cmu.edu
|
||
|
</ADDRESS>
|
||
|
</BODY>
|