84 lines
5.4 KiB
HTML
84 lines
5.4 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.3. Defaulting of Initialization Arguments</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<meta name="description" value=" Defaulting of 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=tex2html5347 HREF="node296.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html5345 HREF="node292.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html5339 HREF="node294.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html5349 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html5350 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html5348 HREF="node296.html"> Rules for Initialization </A>
|
|
<B>Up:</B> <A NAME=tex2html5346 HREF="node292.html"> Object Creation and </A>
|
|
<B> Previous:</B> <A NAME=tex2html5340 HREF="node294.html"> Declaring the Validity </A>
|
|
<HR> <P>
|
|
<H3><A NAME=SECTION003219300000000000000>28.1.9.3. Defaulting of Initialization Arguments</A></H3>
|
|
<P>
|
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
|
A <i>default value form</i> can be supplied for an initialization
|
|
argument by using the <tt>:default-initargs</tt> class option. If an
|
|
initialization argument is declared valid by some particular class,
|
|
its default value form might be specified by a different class.
|
|
In this case <tt>:default-initargs</tt> is used to supply a default value
|
|
for an inherited initialization argument.
|
|
<P>
|
|
The <tt>:default-initargs</tt> option is used only to provide default
|
|
values for initialization arguments; it does not declare a symbol as a
|
|
valid initialization argument name. Furthermore, the
|
|
<tt>:default-initargs</tt> option is used only to provide default values for
|
|
initialization arguments when making an instance.
|
|
<P>
|
|
The argument to the <tt>:default-initargs</tt> class option is a list of
|
|
alternating initialization argument names and forms. Each form is the
|
|
default value form for the corresponding initialization
|
|
argument. The default value form of an initialization
|
|
argument is used and evaluated only if that initialization argument
|
|
does not appear in the arguments to <tt>make-instance</tt> and is not
|
|
defaulted by a more specific class. The default value form is
|
|
evaluated in the lexical environment of the <tt>defclass</tt> form that
|
|
supplied it; the result is used as the initialization
|
|
argument's value.
|
|
<P>
|
|
The initialization arguments supplied to <tt>make-instance</tt> are combined
|
|
with defaulted initialization arguments to produce a <i>defaulted initialization argument list</i>. A defaulted initialization
|
|
argument list is a list of alternating initialization argument names and
|
|
values in which unsupplied initialization arguments are defaulted and in
|
|
which the explicitly supplied initialization arguments appear earlier in
|
|
the list than the defaulted initialization arguments. Defaulted
|
|
initialization arguments are ordered according to the order in the class
|
|
precedence list of the classes that supplied the default values.
|
|
<P>
|
|
There is a distinction between the purposes of the
|
|
<tt>:default-initargs</tt> and the <tt>:initform</tt> options with respect to the
|
|
initialization of slots. The <tt>:default-initargs</tt> class option
|
|
provides a mechanism for the user to give a default value form
|
|
for an initialization argument without knowing whether the
|
|
initialization argument initializes a slot or is passed to a method.
|
|
If that initialization argument is not explicitly supplied in a call
|
|
to <tt>make-instance</tt>, the default value form is used, just
|
|
as if it had been supplied in the call. In contrast, the
|
|
<tt>:initform</tt> slot option provides a mechanism for the user to give a
|
|
default initial value form for a slot. An <tt>:initform</tt> form is
|
|
used to initialize a slot only if no initialization argument
|
|
associated with that slot is given as an argument to
|
|
<tt>make-instance</tt> or is defaulted by <tt>:default-initargs</tt>.
|
|
<P>
|
|
The order of evaluation of default value forms for initialization
|
|
arguments and the order of evaluation of <tt>:initform</tt> forms are
|
|
undefined. If the order of evaluation matters, use
|
|
<tt>initialize-instance</tt> or <tt>shared-initialize</tt> methods.
|
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
|
<P>
|
|
<BR> <HR><A NAME=tex2html5347 HREF="node296.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html5345 HREF="node292.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html5339 HREF="node294.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html5349 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html5350 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html5348 HREF="node296.html"> Rules for Initialization </A>
|
|
<B>Up:</B> <A NAME=tex2html5346 HREF="node292.html"> Object Creation and </A>
|
|
<B> Previous:</B> <A NAME=tex2html5340 HREF="node294.html"> Declaring the Validity </A>
|
|
<HR> <P>
|
|
<HR>
|
|
<P><ADDRESS>
|
|
AI.Repository@cs.cmu.edu
|
|
</ADDRESS>
|
|
</BODY>
|