Christophe Rhodes <csr21@cam.ac.uk> wrote:
+---------------
| "Karsten Poeck" <karsten.poeck.nadadespam@wanadoo.es> writes:
| > In cl-http there are a lot of uses of loop in the following style
| > (simplified)
| > (loop with idx = 0 and end = 3
| > while (< idx end)
| > for char = (aref "012" idx)
| > do (print char)(incf idx))
| >
| > Is the above pattern indeed incorrect?
|
| I believe so.
+---------------
Yup, incorrect. From CLHS "Macro LOOP" <URL:http://www.lispworks.com/
reference/HyperSpec/Body/m_loop.htm>:
loop [name-clause] {variable-clause}* {main-clause}* => result*
...
variable-clause::= with-clause | initial-final | for-as-clause
...
main-clause::= unconditional | accumulation | conditional |
termination-test | initial-final
...
termination-test::= while form | until form | repeat form |
always form | never form | thereis form
Therefore all FOR (and WITH) clauses must precede all WHILE clauses.
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607