| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 2 |
<html> |
| 3 |
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ --> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 |
<title>Processing of Top Level Forms (ANSI and GNU Common Lisp Document)</title> |
| 7 |
|
| 8 |
<meta name="description" content="Processing of Top Level Forms (ANSI and GNU Common Lisp Document)"> |
| 9 |
<meta name="keywords" content="Processing of Top Level Forms (ANSI and GNU Common Lisp Document)"> |
| 10 |
<meta name="resource-type" content="document"> |
| 11 |
<meta name="distribution" content="global"> |
| 12 |
<meta name="Generator" content="makeinfo"> |
| 13 |
<link href="index.html" rel="start" title="Top"> |
| 14 |
<link href="File-Compilation.html" rel="up" title="File Compilation"> |
| 15 |
<link href="Processing-of-Defining-Macros.html" rel="next" title="Processing of Defining Macros"> |
| 16 |
<link href="File-Compilation.html" rel="prev" title="File Compilation"> |
| 17 |
<style type="text/css"> |
| 18 |
<!-- |
| 19 |
a.summary-letter {text-decoration: none} |
| 20 |
blockquote.indentedblock {margin-right: 0em} |
| 21 |
div.display {margin-left: 3.2em} |
| 22 |
div.example {margin-left: 3.2em} |
| 23 |
div.lisp {margin-left: 3.2em} |
| 24 |
kbd {font-style: oblique} |
| 25 |
pre.display {font-family: inherit} |
| 26 |
pre.format {font-family: inherit} |
| 27 |
pre.menu-comment {font-family: serif} |
| 28 |
pre.menu-preformatted {font-family: serif} |
| 29 |
span.nolinebreak {white-space: nowrap} |
| 30 |
span.roman {font-family: initial; font-weight: normal} |
| 31 |
span.sansserif {font-family: sans-serif; font-weight: normal} |
| 32 |
ul.no-bullet {list-style: none} |
| 33 |
--> |
| 34 |
</style> |
| 35 |
|
| 36 |
|
| 37 |
</head> |
| 38 |
|
| 39 |
<body lang="en"> |
| 40 |
<span id="Processing-of-Top-Level-Forms"></span><div class="header"> |
| 41 |
<p> |
| 42 |
Next: <a href="Processing-of-Defining-Macros.html" accesskey="n" rel="next">Processing of Defining Macros</a>, Previous: <a href="File-Compilation.html" accesskey="p" rel="prev">File Compilation</a>, Up: <a href="File-Compilation.html" accesskey="u" rel="up">File Compilation</a> </p> |
| 43 |
</div> |
| 44 |
<hr> |
| 45 |
<span id="Processing-of-Top-Level-Forms-1"></span><h4 class="subsubsection">3.2.3.1 Processing of Top Level Forms</h4> |
| 46 |
|
| 47 |
<p>Processing of <i>top level forms</i> in the file compiler is defined |
| 48 |
as follows: |
| 49 |
</p> |
| 50 |
<dl compact="compact"> |
| 51 |
<dt>1.</dt> |
| 52 |
<dd><p>If the <i>form</i> is a <i>compiler macro form</i> |
| 53 |
(not disabled by a <b>notinline</b> <i>declaration</i>), |
| 54 |
the <i>implementation</i> might or might not choose to compute |
| 55 |
the <i>compiler macro expansion</i> of the <i>form</i> and, |
| 56 |
having performed the expansion, might or might not choose to process the result |
| 57 |
as a <i>top level form</i> in the same processing mode |
| 58 |
(compile-time-too or not-compile-time). |
| 59 |
If it declines to obtain or use the expansion, it must process the original <i>form</i>. |
| 60 |
</p> |
| 61 |
</dd> |
| 62 |
<dt>2.</dt> |
| 63 |
<dd><p>If the form is a <i>macro form</i>, |
| 64 |
its <i>macro expansion</i> is computed and processed as a |
| 65 |
<i>top level form</i> in |
| 66 |
the same processing mode (compile-time-too or not-compile-time). |
| 67 |
</p> |
| 68 |
</dd> |
| 69 |
<dt>3.</dt> |
| 70 |
<dd><p>If the form is a <b>progn</b> form, each of its |
| 71 |
body <i>forms</i> is sequentially processed as a |
| 72 |
<i>top level form</i> in the same processing mode. |
| 73 |
</p> |
| 74 |
</dd> |
| 75 |
<dt>4.</dt> |
| 76 |
<dd><p>If the form is a <b>locally</b>, |
| 77 |
<b>macrolet</b>, or <b>symbol-macrolet</b>, |
| 78 |
<b>compile-file</b> establishes the appropriate bindings and processes the |
| 79 |
body forms as <i>top level forms</i> with those bindings in effect |
| 80 |
in the same processing mode. (Note that this implies that the lexical |
| 81 |
<i>environment</i> in which <i>top level forms</i> are processed |
| 82 |
is not necessarily the <i>null lexical environment</i>.) |
| 83 |
</p> |
| 84 |
</dd> |
| 85 |
<dt>5.</dt> |
| 86 |
<dd><p>If the form is an <b>eval-when</b> |
| 87 |
<span id="index-eval_002dwhen"></span> |
| 88 |
form, it is |
| 89 |
handled according to Figure 3–7. |
| 90 |
</p> |
| 91 |
<p>plus .5 fil |
| 92 |
\offinterlineskip |
| 93 |
</p><div class="format"> |
| 94 |
<pre class="format"> <b>CT</b> <b>LT</b> <b>E</b> <b>Mode</b> <b>Action</b> <b>New Mode</b> <!-- /@w --> |
| 95 |
_________________________________________________<!-- /@w --> |
| 96 |
Yes Yes — — Process compile-time-too <!-- /@w --> |
| 97 |
No Yes Yes CTT Process compile-time-too <!-- /@w --> |
| 98 |
No Yes Yes NCT Process not-compile-time <!-- /@w --> |
| 99 |
No Yes No — Process not-compile-time <!-- /@w --> |
| 100 |
Yes No — — Evaluate — <!-- /@w --> |
| 101 |
No No Yes CTT Evaluate — <!-- /@w --> |
| 102 |
No No Yes NCT Discard — <!-- /@w --> |
| 103 |
No No No — Discard — <!-- /@w --> |
| 104 |
</pre></div> |
| 105 |
|
| 106 |
<p> Figure 3–7: <span class="nolinebreak">EVAL-WHEN</span> processing<!-- /@w --> |
| 107 |
</p> |
| 108 |
<p>Column <b>CT</b> indicates whether <tt>:compile-toplevel</tt> is specified. |
| 109 |
Column <b>LT</b> indicates whether <tt>:load-toplevel</tt> is specified. |
| 110 |
Column <b>E</b> indicates whether <tt>:execute</tt> is specified. |
| 111 |
Column <b>Mode</b> indicates the processing mode; |
| 112 |
a dash (—) indicates that the processing mode is not relevant. |
| 113 |
</p> |
| 114 |
<p>The <b>Action</b> column specifies one of three actions: |
| 115 |
</p> |
| 116 |
<dl compact="compact"> |
| 117 |
<dt><tt></tt></dt> |
| 118 |
<dd><p><b>Process:</b> process the body as <i>top level forms</i> in the |
| 119 |
specified mode. |
| 120 |
</p> |
| 121 |
</dd> |
| 122 |
<dt><tt></tt></dt> |
| 123 |
<dd><p><b>Evaluate:</b> evaluate the body in the dynamic execution |
| 124 |
context of the compiler, using the <i>evaluation environment</i> as |
| 125 |
the global environment and the <i>lexical environment</i> in which |
| 126 |
the <b>eval-when</b> appears. |
| 127 |
</p> |
| 128 |
</dd> |
| 129 |
<dt><tt></tt></dt> |
| 130 |
<dd><p><b>Discard:</b> ignore the <i>form</i>. |
| 131 |
</p></dd> |
| 132 |
</dl> |
| 133 |
|
| 134 |
<p>The <b>New Mode</b> column indicates the new processing mode. |
| 135 |
A dash (—) indicates the compiler remains in its current mode. |
| 136 |
</p> |
| 137 |
</dd> |
| 138 |
<dt>6.</dt> |
| 139 |
<dd><p>Otherwise, the form is a <i>top level form</i> that |
| 140 |
is not one of the special cases. In compile-time-too mode, the |
| 141 |
compiler first evaluates the form in the evaluation |
| 142 |
<i>environment</i> and then minimally compiles it. In not-compile-time |
| 143 |
mode, the <i>form</i> is simply minimally compiled. All <i>subforms</i> |
| 144 |
are treated as <i>non-top-level forms</i>. |
| 145 |
</p> |
| 146 |
<p>Note that <i>top level forms</i> are processed in the order in |
| 147 |
which they textually appear in the file and that each |
| 148 |
<i>top level form</i> read by the compiler is processed before the next is |
| 149 |
read. However, the order of processing (including macro expansion) of |
| 150 |
<i>subforms</i> that are not <i>top level forms</i> and the order of |
| 151 |
further compilation is unspecified as long as Common Lisp semantics |
| 152 |
are preserved. |
| 153 |
</p> |
| 154 |
</dd> |
| 155 |
</dl> |
| 156 |
|
| 157 |
<p><b>eval-when</b> forms cause compile-time evaluation only at |
| 158 |
top level. Both <tt>:compile-toplevel</tt> and <tt>:load-toplevel</tt> situation specifications |
| 159 |
are ignored for <i>non-top-level forms</i>. For <i>non-top-level forms</i>, |
| 160 |
an <b>eval-when</b> |
| 161 |
specifying the <tt>:execute</tt> situation is treated as an <i>implicit progn</i> |
| 162 |
including the <i>forms</i> in the body of the <b>eval-when</b> <i>form</i>; |
| 163 |
otherwise, the <i>forms</i> in the body are ignored. |
| 164 |
</p> |
| 165 |
<hr> |
| 166 |
<div class="header"> |
| 167 |
<p> |
| 168 |
Next: <a href="Processing-of-Defining-Macros.html" accesskey="n" rel="next">Processing of Defining Macros</a>, Previous: <a href="File-Compilation.html" accesskey="p" rel="prev">File Compilation</a>, Up: <a href="File-Compilation.html" accesskey="u" rel="up">File Compilation</a> </p> |
| 169 |
</div> |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
</body> |
| 174 |
</html> |