34 lines
7 KiB
HTML
34 lines
7 KiB
HTML
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>CLHS: Section 7.1.1</TITLE>
|
|
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
|
|
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
|
|
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
|
|
<LINK REL=TOP HREF="../Front/index.htm">
|
|
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
|
|
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
|
|
<LINK REL=PREV HREF="07_a.htm">
|
|
<LINK REL=UP HREF="07_a.htm">
|
|
<LINK REL=NEXT HREF="07_ab.htm">
|
|
</HEAD>
|
|
<BODY>
|
|
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="07_a.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="07_a.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="07_ab.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<H2>
|
|
7.1.1 Initialization Arguments</H2> <P>
|
|
An initialization argument controls <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> creation and initialization. It is often convenient to use keyword <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbols</I></A> to name initialization arguments, but the <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> of an initialization argument can be any <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>, including <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. An initialization argument can be used in two ways: to fill a <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> with a value or to provide an argument for an initialization <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A>. A single initialization argument can be used for both purposes. <P>
|
|
An <A REL=DEFINITION HREF="26_glo_i.htm#initialization_argument_list"><I>initialization argument list</I></A> is a <A REL=DEFINITION HREF="26_glo_p.htm#property_list"><I>property list</I></A> of initialization argument names and values. Its structure is identical to a <A REL=DEFINITION HREF="26_glo_p.htm#property_list"><I>property list</I></A> 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 <A REL=DEFINITION HREF="f_mk_ins.htm#make-instance"><B>make-instance</B></A> (after the first argument) form an <A REL=DEFINITION HREF="26_glo_i.htm#initialization_argument_list"><I>initialization argument list</I></A>. <P>
|
|
An initialization argument can be associated with a <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. If the initialization argument has a value in the <A REL=DEFINITION HREF="26_glo_i.htm#initialization_argument_list"><I>initialization argument list</I></A>, the value is stored into the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> of the newly created <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>, overriding any <TT>:initform</TT> form associated with the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. A single initialization argument can initialize more than one <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. An initialization argument that initializes a <A REL=DEFINITION HREF="26_glo_s.htm#shared_slot"><I>shared slot</I></A> stores its value into the <A REL=DEFINITION HREF="26_glo_s.htm#shared_slot"><I>shared slot</I></A>, replacing any previous value. <P>
|
|
An initialization argument can be associated with a <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A>. When an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> is created and a particular initialization argument is supplied, the <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic functions</I></A> <A REL=DEFINITION HREF="f_init_i.htm#initialize-instance"><B>initialize-instance</B></A>, <A REL=DEFINITION HREF="f_shared.htm#shared-initialize"><B>shared-initialize</B></A>, and <A REL=DEFINITION HREF="f_alloca.htm#allocate-instance"><B>allocate-instance</B></A> 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 <A REL=DEFINITION HREF="26_glo_i.htm#initialization_argument_list"><I>initialization argument list</I></A>, the <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A>'s <A REL=DEFINITION HREF="26_glo_l.htm#lambda_list"><I>lambda list</I></A> supplies a default value. <P>
|
|
Initialization arguments are used in four situations: when making an <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A>, when re-initializing an <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A>, when updating an <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A> to conform to a redefined <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>, and when updating an <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A> to conform to the definition of a different <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>. <P>
|
|
Because initialization arguments are used to control the creation and initialization of an <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A> of some particular <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>, we say that an initialization argument is ``an initialization argument for'' that <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>. <P>
|
|
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss197.htm">INITIALIZATION-FUNCTION-KEYWORD-CHECKING</A><LI> <A REL=CHILD HREF="../Issues/iss269.htm">PLIST-DUPLICATES:ALLOW</A><P></UL><HR>
|
|
|
|
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
|
|
|
|
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
|
|
</BODY>
|
|
</HTML>
|