1
0
Fork 0
cl-sites/www.cs.cmu.edu/Groups/AI/html/cltl/clm/node241.html

62 lines
3 KiB
HTML
Raw Normal View History

2023-10-25 11:23:21 +02:00
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE>26.3.3. Loop Syntax</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Loop Syntax">
<meta name="keywords" value="clm">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<b>Common Lisp the Language, 2nd Edition</b>
<BR> <HR><A NAME=tex2html4580 HREF="node242.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html4578 HREF="node238.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html4574 HREF="node240.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html4582 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html4583 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html4581 HREF="node242.html"> User Extensibility</A>
<B>Up:</B> <A NAME=tex2html4579 HREF="node238.html"> Parsing Loop Clauses</A>
<B> Previous:</B> <A NAME=tex2html4575 HREF="node240.html"> Kinds of Loop </A>
<HR> <P>
<H2><A NAME=SECTION003033000000000000000>26.3.3. Loop Syntax</A></H2>
<P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
The following syntax description provides an overview of the syntax
for loop clauses. Detailed syntax descriptions of individual clauses
appear in sections <A HREF="node244.html#LOOPITERATIONSECTION">26.6</A> through <A HREF="node250.html#LOOPMISCSECTION">26.12</A>.
A loop consists of the
following types of clauses:
<P>
<PRE>
<i>initial-final</i> ::= <i>initially</i> | <i>finally</i>
<i>variables</i> ::= <i>with</i> | <i>initial-final</i> | <i>for-as</i> | <i>repeat</i>
<i>main</i> ::= <i>unconditional</i> | <i>accumulation</i> | <i>conditional</i>
| <i>termination</i> | <i>initial-final</i>
<i>loop</i> ::= (loop [named <i>name</i>] {<i>variables</i>}* {<i>main</i>}*)
</PRE>
<P>
Note that a loop must have at least one clause; however, for
backward compatibility, the following format is also supported:
<P><pre>
(loop {<i>tag</i> | <i>expr</i>}*)
</pre><P>
where <i>expr</i> is any Common Lisp expression that can be evaluated, and
<i>tag</i> is any symbol not identifiable as a loop keyword. Such a format
is roughly equivalent to the following one:
<P>
<P><pre>
(loop do {<i>tag</i> | <i>expr</i>}*)
</pre><P>
<P>
A loop prologue consists of any automatic variable initializations prescribed
by the <i>variable</i> clauses, along with any <i>initially</i> clauses
in the order they appear in the source.
<P>
A loop epilogue consists of <i>finally</i> clauses, if any, along
with any implicit return value from an <i>accumulation</i> clause or
an <i>end-test</i> clause.
<P>
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<HR>
<P><ADDRESS>
AI.Repository@cs.cmu.edu
</ADDRESS>
</BODY>