80 lines
4.9 KiB
HTML
80 lines
4.9 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>28.1.9.1. Initialization Arguments</TITLE>
|
||
|
</HEAD>
|
||
|
<BODY>
|
||
|
<meta name="description" value=" Initialization Arguments">
|
||
|
<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=tex2html5323 HREF="node294.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html5321 HREF="node292.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html5315 HREF="node292.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html5325 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html5326 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
||
|
<B> Next:</B> <A NAME=tex2html5324 HREF="node294.html"> Declaring the Validity </A>
|
||
|
<B>Up:</B> <A NAME=tex2html5322 HREF="node292.html"> Object Creation and </A>
|
||
|
<B> Previous:</B> <A NAME=tex2html5316 HREF="node292.html"> Object Creation and </A>
|
||
|
<HR> <P>
|
||
|
<H3><A NAME=SECTION003219100000000000000>28.1.9.1. Initialization Arguments</A></H3>
|
||
|
<P>
|
||
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
||
|
An initialization argument controls object creation and
|
||
|
initialization. It is often convenient to use keyword symbols to name
|
||
|
initialization arguments, but the name of an initialization argument
|
||
|
can be any symbol, including <tt>nil</tt>. An initialization argument
|
||
|
can be used in two ways: to fill a slot with a value or to provide an
|
||
|
argument for an initialization method. A single initialization
|
||
|
argument can be used for both purposes.
|
||
|
<P>
|
||
|
An <i>initialization argument list</i> is a list of alternating
|
||
|
initialization argument names and values. Its structure is identical
|
||
|
to a property list and also to the portion of an argument list
|
||
|
processed for <tt>&key</tt> parameters. As in those lists, if an
|
||
|
initialization argument name appears more than once in an
|
||
|
initialization argument list, the leftmost occurrence supplies the
|
||
|
value and the remaining occurrences are ignored. The arguments to
|
||
|
<tt>make-instance</tt> (after the first argument) form an initialization
|
||
|
argument list. Error checking of initialization argument names is
|
||
|
disabled if the keyword argument pair whose keyword is
|
||
|
<tt>:allow-other-keys</tt> and whose value is non-<tt>nil</tt> appears in the
|
||
|
initialization argument list.
|
||
|
<P>
|
||
|
An initialization argument can be associated with a slot. If the
|
||
|
initialization argument has a value in the initialization argument
|
||
|
list, the value is stored into the slot of the newly created object,
|
||
|
overriding any <tt>:initform</tt> form associated with the slot. A
|
||
|
single initialization argument can initialize more than one slot. An
|
||
|
initialization argument that initializes a shared slot stores its
|
||
|
value into the shared slot, replacing any previous value.
|
||
|
<P>
|
||
|
An initialization argument can be associated with a method. When an
|
||
|
object is created and a particular initialization argument is
|
||
|
supplied, the generic functions <tt>initialize-instance</tt>,
|
||
|
<tt>shared-initialize</tt>, and <tt>allocate-instance</tt> are called with that
|
||
|
initialization argument's name and value as a keyword argument pair.
|
||
|
If a value for the initialization argument is not supplied in the
|
||
|
initialization argument list, the method's lambda-list supplies a
|
||
|
default value.
|
||
|
<P>
|
||
|
Initialization arguments are used in four situations: when making an
|
||
|
instance, when re-initializing an instance, when updating an instance to
|
||
|
conform to a redefined class, and when updating an instance to conform
|
||
|
to the definition of a different class.
|
||
|
<P>
|
||
|
Because initialization arguments are used to control the creation and
|
||
|
initialization of an instance of some particular class, we say that an
|
||
|
initialization argument is ``an initialization argument for'' that
|
||
|
class.
|
||
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
||
|
<P>
|
||
|
<BR> <HR><A NAME=tex2html5323 HREF="node294.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html5321 HREF="node292.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html5315 HREF="node292.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html5325 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html5326 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
||
|
<B> Next:</B> <A NAME=tex2html5324 HREF="node294.html"> Declaring the Validity </A>
|
||
|
<B>Up:</B> <A NAME=tex2html5322 HREF="node292.html"> Object Creation and </A>
|
||
|
<B> Previous:</B> <A NAME=tex2html5316 HREF="node292.html"> Object Creation and </A>
|
||
|
<HR> <P>
|
||
|
<HR>
|
||
|
<P><ADDRESS>
|
||
|
AI.Repository@cs.cmu.edu
|
||
|
</ADDRESS>
|
||
|
</BODY>
|