1
0
Fork 0
cl-sites/www.cs.cmu.edu/Groups/AI/html/cltl/clm/node294.html
2023-10-25 11:23:21 +02:00

92 lines
5.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>28.1.9.2. Declaring the Validity of Initialization Arguments</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Declaring the Validity 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=tex2html5335 HREF="node295.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html5333 HREF="node292.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html5327 HREF="node293.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html5337 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html5338 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html5336 HREF="node295.html"> Defaulting of Initialization </A>
<B>Up:</B> <A NAME=tex2html5334 HREF="node292.html"> Object Creation and </A>
<B> Previous:</B> <A NAME=tex2html5328 HREF="node293.html"> Initialization Arguments</A>
<HR> <P>
<H3><A NAME=SECTION003219200000000000000>28.1.9.2. Declaring the Validity of Initialization Arguments</A></H3>
<P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
<A NAME=DeclaringtheValidityofInitializationArgumentsSECTION>Initialization</A>
arguments are checked for validity in each of the four
situations that use them. An initialization argument may be valid in
one situation and not another. For example, the system-supplied
primary method for <tt>make-instance</tt> defined for the class
<tt>standard-class</tt> checks the validity of its initialization arguments
and signals an error if an initialization argument is supplied that is
not declared valid in that situation.
<P>
There are two means of declaring initialization arguments valid.
<P>
<UL><LI> Initialization arguments that fill slots are declared
valid by the <tt>:initarg</tt> slot option to <tt>defclass</tt>. The
<tt>:initarg</tt> slot option is inherited from superclasses. Thus the set of
valid initialization arguments that fill slots for a class is the
union of the initialization arguments that fill slots declared
valid by that class and its superclasses. Initialization arguments
that fill slots are valid in all four contexts.
<P>
<LI> Initialization arguments that supply arguments to methods
are declared valid by defining those methods. The keyword name of
each keyword parameter specified in the method's lambda-list becomes
an initialization argument for all classes for which the method is
applicable. Thus method inheritance controls the set of valid
initialization arguments that supply arguments to methods. The
generic functions for which method definitions serve to declare
initialization arguments valid are as follows:
<P>
<UL><LI> Making an instance of a class: <tt>allocate-instance</tt>,
<tt>initialize-instance</tt>, and <tt>shared-initialize</tt>.
Initialization arguments declared valid by these methods are
valid when making an instance of a class.
<P>
<LI> Re-initializing an instance: the functions <tt>reinitialize-instance</tt>
and <tt>shared-initialize</tt>.
Initialization arguments declared valid by these methods are
valid when re-initializing an instance.
<P>
<LI> Updating an instance to conform to a redefined class:
<tt>update-instance-for-redefined-class</tt>
and <tt>shared-initialize</tt>.
Initialization arguments declared valid by these methods are
valid when updating an instance to conform to a redefined class.
<P>
<LI> Updating an instance to conform to the definition of a
different class: <tt>update-instance-for-different-class</tt> and
<tt>shared-initialize</tt>.
Initialization arguments declared valid by these methods are
valid when updating an instance to conform to the definition
of a different class.
</UL>
</UL>
<P>
The set of valid initialization arguments for a class is the set of
valid initialization arguments that either fill slots or supply
arguments to methods, along with the predefined initialization
argument <tt>:allow-other-keys</tt>. The default value for
<tt>:allow-other-keys</tt> is <tt>nil</tt>. The meaning of
<tt>:allow-other-keys</tt> is the same here as when it is passed to an ordinary
function.
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<P>
<BR> <HR><A NAME=tex2html5335 HREF="node295.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html5333 HREF="node292.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html5327 HREF="node293.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html5337 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html5338 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html5336 HREF="node295.html"> Defaulting of Initialization </A>
<B>Up:</B> <A NAME=tex2html5334 HREF="node292.html"> Object Creation and </A>
<B> Previous:</B> <A NAME=tex2html5328 HREF="node293.html"> Initialization Arguments</A>
<HR> <P>
<HR>
<P><ADDRESS>
AI.Repository@cs.cmu.edu
</ADDRESS>
</BODY>