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

45 lines
6.1 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 5.1.1.2</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="05_aaaa.htm">
<LINK REL=UP HREF="05_aa.htm">
<LINK REL=NEXT HREF="05_aaba.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="05_aaaa.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="05_aa.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="05_aaba.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>
5.1.1.2 Setf Expansions</H2> <P>
Sometimes it is possible to avoid evaluating <A REL=DEFINITION HREF="26_glo_s.htm#subform"><I>subforms</I></A> of a <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>place</I></A> multiple times or in the wrong order. A <A REL=DEFINITION HREF="26_glo_s.htm#setf_expansion"><I>setf expansion</I></A> for a given access form can be expressed as an ordered collection of five <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>objects</I></A>: <P>
<P><DL><DT><B>List of temporary variables</B> <P><DD>
a list of symbols naming temporary variables to be bound sequentially, as if by <A REL=DEFINITION HREF="s_let_l.htm#letST"><B>let*</B></A>, to <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>values</I></A> resulting from value forms. <P>
<DT><B>List of value forms</B> <P><DD>
a list of forms (typically, <A REL=DEFINITION HREF="26_glo_s.htm#subform"><I>subforms</I></A> of the <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>place</I></A>) which when evaluated yield the values to which the corresponding temporary variables should be bound. <P>
<DT><B>List of store variables</B> <P><DD>
a list of symbols naming temporary store variables which are to hold the new values that will be assigned to the <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>place</I></A>. <P>
<DT><B>Storing form</B> <P><DD>
a form which can reference both the temporary and the store variables, and which changes the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of the <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>place</I></A> and guarantees to return as its values the values of the store variables, which are the correct values for <A REL=DEFINITION HREF="m_setf_.htm#setf"><B>setf</B></A> to return. <P>
<DT><B>Accessing form</B> <P><DD>
a <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> which can reference the temporary variables, and which returns the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of the <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>place</I></A>. <P></DL><P>
The value returned by the accessing form is affected by execution of the storing form, but either of these forms might be evaluated any number of times. <P>
It is possible to do more than one <A REL=DEFINITION HREF="m_setf_.htm#setf"><B>setf</B></A> in parallel via <A REL=DEFINITION HREF="m_setf_.htm#psetf"><B>psetf</B></A>, <A REL=DEFINITION HREF="m_shiftf.htm#shiftf"><B>shiftf</B></A>, and <A REL=DEFINITION HREF="m_rotate.htm#rotatef"><B>rotatef</B></A>. Because of this, the <A REL=DEFINITION HREF="26_glo_s.htm#setf_expander"><I>setf expander</I></A> must produce new temporary and store variable names every time. For examples of how to do this, see <A REL=DEFINITION HREF="f_gensym.htm#gensym"><B>gensym</B></A>. <P>
For each <A REL=DEFINITION HREF="26_glo_s.htm#standardized"><I>standardized</I></A> accessor function <I>F</I>, unless it is explicitly documented otherwise, it is <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A> whether the ability to use an <I>F</I> <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> as a <A REL=DEFINITION HREF="m_setf_.htm#setf"><B>setf</B></A> <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>place</I></A> is implemented by a <A REL=DEFINITION HREF="26_glo_s.htm#setf_expander"><I>setf expander</I></A> or a <A REL=DEFINITION HREF="26_glo_s.htm#setf_function"><I>setf function</I></A>. Also, it follows from this that it is <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A> whether the name <TT>(setf </TT><I>F</I><TT>)</TT> is <A REL=DEFINITION HREF="26_glo_f.htm#fbound"><I>fbound</I></A>. <P>
<A REL=CHILD HREF="05_aaba.htm"><H2>
5.1.1.2.1 Examples of Setf Expansions</H2></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/iss305.htm">SETF-FUNCTIONS-AGAIN:MINIMAL-CHANGES</A><LI> <A REL=CHILD HREF="../Issues/iss308.htm">SETF-METHOD-VS-SETF-METHOD:RENAME-OLD-TERMS</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>