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

52 lines
7.9 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.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="05_aa.htm">
<LINK REL=UP HREF="05_aa.htm">
<LINK REL=NEXT HREF="05_aaaa.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_aa.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_aaaa.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>
5.1.1.1 Evaluation of Subforms to Places</H2> <P>
The following rules apply to the <A REL=DEFINITION HREF="26_glo_e.htm#evaluation"><I>evaluation</I></A> of <A REL=DEFINITION HREF="26_glo_s.htm#subform"><I>subforms</I></A> in a <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>place</I></A>: <P>
<P><DL><DT>1. The evaluation ordering of <A REL=DEFINITION HREF="26_glo_s.htm#subform"><I>subforms</I></A> within a <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>place</I></A> is determined by the order specified by the second value returned by <A REL=DEFINITION HREF="f_get_se.htm#get-setf-expansion"><B>get-setf-expansion</B></A>. For all <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>places</I></A> defined by this specification (e.g., <A REL=DEFINITION HREF="f_getf.htm#getf"><B>getf</B></A>, <A REL=DEFINITION HREF="f_ldb.htm#ldb"><B>ldb</B></A>, ...), this order of evaluation is left-to-right. When a <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>place</I></A> is derived from a macro expansion, this rule is applied after the macro is expanded to find the appropriate <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>place</I></A>. <P><DD>
<A REL=DEFINITION HREF="26_glo_p.htm#place"><I>Places</I></A> defined by using <A REL=DEFINITION HREF="m_defmac.htm#defmacro"><B>defmacro</B></A> or <A REL=DEFINITION HREF="m_defi_3.htm#define-setf-expander"><B>define-setf-expander</B></A> use the evaluation order defined by those definitions. For example, consider the following: <P>
<PRE>
(defmacro wrong-order (x y) `(getf ,y ,x))
</PRE>
</TT> <P>
This following <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> evaluates <TT>place2</TT> first and then <TT>place1</TT> because that is the order they are evaluated in the macro expansion: <P>
<PRE>
(push value (wrong-order place1 place2))
</PRE>
</TT> <P>
<DT>2. For the <A REL=DEFINITION HREF="26_glo_m.htm#macro"><I>macros</I></A> that manipulate <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>places</I></A> (<A REL=DEFINITION HREF="m_push.htm#push"><B>push</B></A>, <A REL=DEFINITION HREF="m_pshnew.htm#pushnew"><B>pushnew</B></A>, <A REL=DEFINITION HREF="m_remf.htm#remf"><B>remf</B></A>, <A REL=DEFINITION HREF="m_incf_.htm#incf"><B>incf</B></A>, <A REL=DEFINITION HREF="m_incf_.htm#decf"><B>decf</B></A>, <A REL=DEFINITION HREF="m_shiftf.htm#shiftf"><B>shiftf</B></A>, <A REL=DEFINITION HREF="m_rotate.htm#rotatef"><B>rotatef</B></A>, <A REL=DEFINITION HREF="m_setf_.htm#psetf"><B>psetf</B></A>, <A REL=DEFINITION HREF="m_setf_.htm#setf"><B>setf</B></A>, <A REL=DEFINITION HREF="m_pop.htm#pop"><B>pop</B></A>, and those defined by <A REL=DEFINITION HREF="m_defi_2.htm#define-modify-macro"><B>define-modify-macro</B></A>) the <A REL=DEFINITION HREF="26_glo_s.htm#subform"><I>subforms</I></A> of the macro call are evaluated exactly once in left-to-right order, with the <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>places</I></A> evaluated in the order specified in (1). <P><DD>
<A REL=DEFINITION HREF="m_push.htm#push"><B>push</B></A>, <A REL=DEFINITION HREF="m_pshnew.htm#pushnew"><B>pushnew</B></A>, <A REL=DEFINITION HREF="m_remf.htm#remf"><B>remf</B></A>, <A REL=DEFINITION HREF="m_incf_.htm#incf"><B>incf</B></A>, <A REL=DEFINITION HREF="m_incf_.htm#decf"><B>decf</B></A>, <A REL=DEFINITION HREF="m_shiftf.htm#shiftf"><B>shiftf</B></A>, <A REL=DEFINITION HREF="m_rotate.htm#rotatef"><B>rotatef</B></A>, <A REL=DEFINITION HREF="m_setf_.htm#psetf"><B>psetf</B></A>, <A REL=DEFINITION HREF="m_pop.htm#pop"><B>pop</B></A> evaluate all <A REL=DEFINITION HREF="26_glo_s.htm#subform"><I>subforms</I></A> before modifying any of the <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>place</I></A> locations. <A REL=DEFINITION HREF="m_setf_.htm#setf"><B>setf</B></A> (in the case when <A REL=DEFINITION HREF="m_setf_.htm#setf"><B>setf</B></A> has more than two arguments) performs its operation on each pair in sequence. For example, in <P>
<PRE>
(setf place1 value1 place2 value2 ...)
</PRE>
</TT> the <A REL=DEFINITION HREF="26_glo_s.htm#subform"><I>subforms</I></A> of <TT>place1</TT> and <TT>value1</TT> are evaluated, the location specified by <TT>place1</TT> is modified to contain the value returned by <TT>value1</TT>, and then the rest of the <A REL=DEFINITION HREF="m_setf_.htm#setf"><B>setf</B></A> form is processed in a like manner. <P>
<DT>3. For <A REL=DEFINITION HREF="m_check_.htm#check-type"><B>check-type</B></A>, <A REL=DEFINITION HREF="m_tpcase.htm#ctypecase"><B>ctypecase</B></A>, and <A REL=DEFINITION HREF="m_case_.htm#ccase"><B>ccase</B></A>, <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> are evaluated once as in (1), but might be evaluated again if the type check fails in the case of <A REL=DEFINITION HREF="m_check_.htm#check-type"><B>check-type</B></A> or none of the cases hold in <A REL=DEFINITION HREF="m_tpcase.htm#ctypecase"><B>ctypecase</B></A> and <A REL=DEFINITION HREF="m_case_.htm#ccase"><B>ccase</B></A>. <P><DD>
<DT>4. For <A REL=DEFINITION HREF="m_assert.htm#assert"><B>assert</B></A>, the order of evaluation of the generalized references is not specified. <P><DD>
<P></DL>Rules 2, 3 and 4 cover all <A REL=DEFINITION HREF="26_glo_s.htm#standardized"><I>standardized</I></A> <A REL=DEFINITION HREF="26_glo_m.htm#macro"><I>macros</I></A> that manipulate <A REL=DEFINITION HREF="26_glo_p.htm#place"><I>places</I></A>. <P>
<A REL=CHILD HREF="05_aaaa.htm"><H2>
5.1.1.1.1 Examples of Evaluation of Subforms to Places</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/iss205.htm">JUN90-TRIVIAL-ISSUES:4</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>