1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/07_ae.htm
2024-04-01 10:24:07 +02:00

41 lines
8 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.5</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_ad.htm">
<LINK REL=UP HREF="07_a.htm">
<LINK REL=NEXT HREF="07_af.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_ad.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_af.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>
7.1.5 Shared-Initialize</H2> <P>
The <A REL=DEFINITION HREF="26_glo_g.htm#generic_function"><I>generic function</I></A> <A REL=DEFINITION HREF="f_shared.htm#shared-initialize"><B>shared-initialize</B></A> is used to fill the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A> of an <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A> using initialization arguments and <TT>:initform</TT> forms when an <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A> is created, when an <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A> is re-initialized, when an <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A> is updated to conform to a redefined <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>, and when an <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A> is updated to conform to a different <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>. It uses standard <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A> combination. It takes the following arguments: the <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A> to be initialized, a specification of a set of <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>names</I></A> of <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A> <A REL=DEFINITION HREF="26_glo_a.htm#accessible"><I>accessible</I></A> in that <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A>, and any number of initialization arguments. The arguments after the first two must form an <A REL=DEFINITION HREF="26_glo_i.htm#initialization_argument_list"><I>initialization argument list</I></A>. <P>
The second argument to <A REL=DEFINITION HREF="f_shared.htm#shared-initialize"><B>shared-initialize</B></A> may be one of the following: <P>
<P><DL><P>
<DT>* It can be a (possibly empty) <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> of <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> names, which specifies the set of those <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> names. <P><DD>
<DT>* It can be the symbol <A REL=DEFINITION HREF="a_t.htm#t"><B>t</B></A>, which specifies the set of all of the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A>. <P><DD>
<P></DL><P>
There is a system-supplied primary <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A> for <A REL=DEFINITION HREF="f_shared.htm#shared-initialize"><B>shared-initialize</B></A> whose first <A REL=DEFINITION HREF="26_glo_p.htm#parameter_specializer"><I>parameter specializer</I></A> is the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> <A REL=DEFINITION HREF="t_std_ob.htm#standard-object"><B>standard-object</B></A>. This <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A> behaves as follows on each <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>, whether shared or local: <P>
<P><DL><P>
<DT>* If an initialization argument in the <A REL=DEFINITION HREF="26_glo_i.htm#initialization_argument_list"><I>initialization argument list</I></A> specifies a value for that <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>, that value is stored into the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>, even if a value has already been stored in the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> before the <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A> is run. The affected <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A> are independent of which <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A> are indicated by the second argument to <A REL=DEFINITION HREF="f_shared.htm#shared-initialize"><B>shared-initialize</B></A>. <P><DD>
<DT>* Any <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A> indicated by the second argument that are still unbound at this point are initialized according to their <TT>:initform</TT> forms. For any such <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A> that has an <TT>:initform</TT> form, that <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> is evaluated in the lexical environment of its defining <A REL=DEFINITION HREF="m_defcla.htm#defclass"><B>defclass</B></A> form and the result is stored into the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. For example, if a <A REL=DEFINITION HREF="26_glo_b.htm#before_method"><I>before method</I></A> stores a value in the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>, the <TT>:initform</TT> form will not be used to supply a value for the <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slot</I></A>. If the second argument specifies a <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> that does not correspond to any <A REL=DEFINITION HREF="26_glo_s.htm#slot"><I>slots</I></A> <A REL=DEFINITION HREF="26_glo_a.htm#accessible"><I>accessible</I></A> in the <A REL=DEFINITION HREF="26_glo_i.htm#instance"><I>instance</I></A>, the results are unspecified. <P><DD>
<DT>* The rules mentioned in <A REL=CHILD HREF="07_ad.htm">Section 7.1.4 (Rules for Initialization Arguments)</A> are obeyed. <P><DD>
<P></DL><P>
The generic function <A REL=DEFINITION HREF="f_shared.htm#shared-initialize"><B>shared-initialize</B></A> is called by the system-supplied primary <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>methods</I></A> for <A REL=DEFINITION HREF="f_reinit.htm#reinitialize-instance"><B>reinitialize-instance</B></A>, <A REL=DEFINITION HREF="f_update.htm#update-instance-for-different-class"><B>update-instance-for-different-class</B></A>, <A REL=DEFINITION HREF="f_upda_1.htm#update-instance-for-redefined-class"><B>update-instance-for-redefined-class</B></A>, and <A REL=DEFINITION HREF="f_init_i.htm#initialize-instance"><B>initialize-instance</B></A>. Thus, <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>methods</I></A> can be written for <A REL=DEFINITION HREF="f_shared.htm#shared-initialize"><B>shared-initialize</B></A> to specify actions that should be taken in all of these contexts. <P>
<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>