From: Karsten Poeck
Subject: Loop "For" clause  after "where" clause?
Date: 
Message-ID: <O4jBc.284497$Rc.8443038@news-reader.eresmas.com>
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))

This fails in one lisp in the aref not using the MIT implementation of loop.
Looking at the macroexpansion it is obvious that the "for char = (aref "012"
idx)" is executed after the test for (< idx end) in the mit-loops and before
in the after.


From the syntax description in dpans 6.2.4
loop [name-clause] {variable-clause}* {main-clause}*    {result}*
it seems that after a while (a main clause) no further for (a variable
clause) is permitted.

Is the above pattern indeed incorrect?

saludos

Karsten

From: Christophe Rhodes
Subject: Re: Loop "For" clause  after "where" clause?
Date: 
Message-ID: <sqhdt6b2r9.fsf@cam.ac.uk>
"Karsten Poeck" <························@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.

Christophe
-- 
http://www-jcsu.jesus.cam.ac.uk/~csr21/       +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%")    (pprint #36rJesusCollegeCambridge)
From: Rob Warnock
Subject: Re: Loop "For" clause  after "where" clause?
Date: 
Message-ID: <UaOdnXwEAOkuqkvdRVn-vA@speakeasy.net>
Christophe Rhodes  <·····@cam.ac.uk> wrote:
+---------------
| "Karsten Poeck" <························@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.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Tim Bradshaw
Subject: Re: Loop "For" clause  after "where" clause?
Date: 
Message-ID: <fbc0f5d1.0406220641.7053786c@posting.google.com>
····@rpw3.org (Rob Warnock) wrote in message news:<······················@speakeasy.net>...
> 
> Therefore all FOR (and WITH) clauses must precede all WHILE clauses.

Yes, this is right - I was bitten by it when trying to port my
(broken) code to ?CMUCL?.

It would be nice to have a list of
implementations-with-fussy-LOOP-macros (and for thost that don't to at
least add a fussy mode)  Here `fussy' means `checking conformance' I
guess.

--tim