68 lines
9.4 KiB
HTML
68 lines
9.4 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 3.2.3.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="03_bc.htm">
|
|
<LINK REL=UP HREF="03_bc.htm">
|
|
<LINK REL=NEXT HREF="03_bcaa.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="03_bc.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="03_bc.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="03_bcaa.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<H2>
|
|
3.2.3.1 Processing of Top Level Forms</H2> <P>
|
|
Processing of <A REL=DEFINITION HREF="26_glo_t.htm#top_level_form"><I>top level forms</I></A> in the file compiler is defined as follows: <P>
|
|
<P><OL> <LI> If the <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> is a <A REL=DEFINITION HREF="26_glo_c.htm#compiler_macro_form"><I>compiler macro form</I></A> (not disabled by a <A REL=DEFINITION HREF="d_inline.htm#notinline"><B>notinline</B></A> <A REL=DEFINITION HREF="26_glo_d.htm#declaration"><I>declaration</I></A>), the <A REL=DEFINITION HREF="26_glo_i.htm#implementation"><I>implementation</I></A> might or might not choose to compute the <A REL=DEFINITION HREF="26_glo_c.htm#compiler_macro_expansion"><I>compiler macro expansion</I></A> of the <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> and, having performed the expansion, might or might not choose to process the result as a <A REL=DEFINITION HREF="26_glo_t.htm#top_level_form"><I>top level form</I></A> in the same processing mode (compile-time-too or not-compile-time). If it declines to obtain or use the expansion, it must process the original <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A>. <P>
|
|
<LI> If the form is a <A REL=DEFINITION HREF="26_glo_m.htm#macro_form"><I>macro form</I></A>, its <A REL=DEFINITION HREF="26_glo_m.htm#macro_expansion"><I>macro expansion</I></A> is computed and processed as a <A REL=DEFINITION HREF="26_glo_t.htm#top_level_form"><I>top level form</I></A> in the same processing mode (compile-time-too or not-compile-time). <P>
|
|
<LI> If the form is a <A REL=DEFINITION HREF="s_progn.htm#progn"><B>progn</B></A> form, each of its body <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>forms</I></A> is sequentially processed as a <A REL=DEFINITION HREF="26_glo_t.htm#top_level_form"><I>top level form</I></A> in the same processing mode. <P>
|
|
<LI> If the form is a <A REL=DEFINITION HREF="s_locall.htm#locally"><B>locally</B></A>, <A REL=DEFINITION HREF="s_flet_.htm#macrolet"><B>macrolet</B></A>, or <A REL=DEFINITION HREF="s_symbol.htm#symbol-macrolet"><B>symbol-macrolet</B></A>, <A REL=DEFINITION HREF="f_cmp_fi.htm#compile-file"><B>compile-file</B></A> establishes the appropriate bindings and processes the body forms as <A REL=DEFINITION HREF="26_glo_t.htm#top_level_form"><I>top level forms</I></A> with those bindings in effect in the same processing mode. (Note that this implies that the lexical <A REL=DEFINITION HREF="26_glo_e.htm#environment"><I>environment</I></A> in which <A REL=DEFINITION HREF="26_glo_t.htm#top_level_form"><I>top level forms</I></A> are processed is not necessarily the <A REL=DEFINITION HREF="26_glo_n.htm#null_lexical_environment"><I>null lexical environment</I></A>.) <P>
|
|
<LI> If the form is an <A REL=DEFINITION HREF="s_eval_w.htm#eval-when"><B>eval-when</B></A> form, it is handled according to the next figure. <P>
|
|
plus .5 fil <PRE>
|
|
|
|
CT LT E Mode Action New Mode
|
|
----------
|
|
|
|
Yes Yes --- --- Process compile-time-too
|
|
No Yes Yes CTT Process compile-time-too
|
|
No Yes Yes NCT Process not-compile-time
|
|
No Yes No --- Process not-compile-time
|
|
Yes No --- --- Evaluate ---
|
|
No No Yes CTT Evaluate ---
|
|
No No Yes NCT Discard ---
|
|
No No No --- Discard ---
|
|
|
|
|
|
</PRE>
|
|
<P><B>Figure 3-7. EVAL-WHEN processing</B> <P>
|
|
Column <B>CT</B> indicates whether <TT>:compile-toplevel</TT> is specified. Column <B>LT</B> indicates whether <TT>:load-toplevel</TT> is specified. Column <B>E</B> indicates whether <TT>:execute</TT> is specified. Column <B>Mode</B> indicates the processing mode; a dash (---) indicates that the processing mode is not relevant. <P>
|
|
The <B>Action</B> column specifies one of three actions: <P>
|
|
<P><DL><P>
|
|
<DT> <B>Process:</B> process the body as <A REL=DEFINITION HREF="26_glo_t.htm#top_level_form"><I>top level forms</I></A> in the specified mode. <P><DD>
|
|
<DT> <B>Evaluate:</B> evaluate the body in the dynamic execution context of the compiler, using the <A REL=DEFINITION HREF="26_glo_e.htm#evaluation_environment"><I>evaluation environment</I></A> as the global environment and the <A REL=DEFINITION HREF="26_glo_l.htm#lexical_environment"><I>lexical environment</I></A> in which the <A REL=DEFINITION HREF="s_eval_w.htm#eval-when"><B>eval-when</B></A> appears. <P><DD>
|
|
<DT> <B>Discard:</B> ignore the <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A>. <P><DD></DL><P>
|
|
The <B>New Mode</B> column indicates the new processing mode. A dash (---) indicates the compiler remains in its current mode. <P>
|
|
<LI> Otherwise, the form is a <A REL=DEFINITION HREF="26_glo_t.htm#top_level_form"><I>top level form</I></A> that is not one of the special cases. In compile-time-too mode, the compiler first evaluates the form in the evaluation <A REL=DEFINITION HREF="26_glo_e.htm#environment"><I>environment</I></A> and then minimally compiles it. In not-compile-time mode, the <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A> is simply minimally compiled. All <A REL=DEFINITION HREF="26_glo_s.htm#subform"><I>subforms</I></A> are treated as <A REL=DEFINITION HREF="26_glo_n.htm#non-top-level_form"><I>non-top-level forms</I></A>. <P>
|
|
Note that <A REL=DEFINITION HREF="26_glo_t.htm#top_level_form"><I>top level forms</I></A> are processed in the order in which they textually appear in the file and that each <A REL=DEFINITION HREF="26_glo_t.htm#top_level_form"><I>top level form</I></A> read by the compiler is processed before the next is read. However, the order of processing (including macro expansion) of <A REL=DEFINITION HREF="26_glo_s.htm#subform"><I>subforms</I></A> that are not <A REL=DEFINITION HREF="26_glo_t.htm#top_level_form"><I>top level forms</I></A> and the order of further compilation is unspecified as long as Common Lisp semantics are preserved. <P>
|
|
<P></OL><P>
|
|
<A REL=DEFINITION HREF="s_eval_w.htm#eval-when"><B>eval-when</B></A> forms cause compile-time evaluation only at top level. Both <TT>:compile-toplevel</TT> and <TT>:load-toplevel</TT> situation specifications are ignored for <A REL=DEFINITION HREF="26_glo_n.htm#non-top-level_form"><I>non-top-level forms</I></A>. For <A REL=DEFINITION HREF="26_glo_n.htm#non-top-level_form"><I>non-top-level forms</I></A>, an <A REL=DEFINITION HREF="s_eval_w.htm#eval-when"><B>eval-when</B></A> specifying the <TT>:execute</TT> situation is treated as an <A REL=DEFINITION HREF="26_glo_i.htm#implicit_progn"><I>implicit progn</I></A> including the <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>forms</I></A> in the body of the <A REL=DEFINITION HREF="s_eval_w.htm#eval-when"><B>eval-when</B></A> <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>form</I></A>; otherwise, the <A REL=DEFINITION HREF="26_glo_f.htm#form"><I>forms</I></A> in the body are ignored. <P>
|
|
|
|
|
|
<A REL=CHILD HREF="03_bcaa.htm"><H2>
|
|
3.2.3.1.1 Processing of Defining Macros</H2></A><P>
|
|
|
|
<A REL=CHILD HREF="03_bcab.htm"><H2>
|
|
3.2.3.1.2 Constraints on Macros and Compiler Macros</H2></A><P><P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issue</A>, <I>not part of the specification</I>, applies to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss101.htm">DEFINE-COMPILER-MACRO:X3J13-NOV89</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>
|