From: Alex Mizrahi
Subject: loop bug?
Date: 
Message-ID: <c1lc2a$1k4mcl$1@ID-177567.news.uni-berlin.de>
Hello, All!

i found strange behaviour in Lispworks (4.2.0):

(loop    for i from 0 to 5
         for j in '(0 1 2 3 4 5)
         and k on '(0 1 2 3 4 5)
         do (format t "~A~A~A~%" i j k))
00(0 1 2 3 4 5)
11(0 1 2 3 4 5)
22(0 1 2 3 4 5)
33(0 1 2 3 4 5)
44(0 1 2 3 4 5)
55(0 1 2 3 4 5)
NIL

while Allegro does it like it's supposed to be:

(loop for i from 0 to 5 for j in '(0 1 2 3 4 5) and k on '(0 1 2 3 4 5) do
(format t "~A~A~A~%" i j k))

00(0 1 2 3 4 5)

11(1 2 3 4 5)

22(2 3 4 5)

33(3 4 5)

44(4 5)

55(5)

NIL

it's a bug in lispworks?

With best regards, Alex Mizrahi.  E-mail: ·········@xhotmail.com

From: Pascal Costanza
Subject: Re: loop bug?
Date: 
Message-ID: <c1lge9$loj$1@newsreader2.netcologne.de>
Yes, seems like a bug. Better post this to the LispWorks mailing, so 
that they will fix this for the next release.

For the records, it also occurs in LispWorks 4.3 personal edition for 
Mac OS X. Macintosh Common Lisp 5.0 does it right.

Pascal

Alex Mizrahi wrote:

> Hello, All!
> 
> i found strange behaviour in Lispworks (4.2.0):
> 
> (loop    for i from 0 to 5
>          for j in '(0 1 2 3 4 5)
>          and k on '(0 1 2 3 4 5)
>          do (format t "~A~A~A~%" i j k))
> 00(0 1 2 3 4 5)
> 11(0 1 2 3 4 5)
> 22(0 1 2 3 4 5)
> 33(0 1 2 3 4 5)
> 44(0 1 2 3 4 5)
> 55(0 1 2 3 4 5)
> NIL
> 
> while Allegro does it like it's supposed to be:
> 
> (loop for i from 0 to 5 for j in '(0 1 2 3 4 5) and k on '(0 1 2 3 4 5) do
> (format t "~A~A~A~%" i j k))
> 
> 00(0 1 2 3 4 5)
> 
> 11(1 2 3 4 5)
> 
> 22(2 3 4 5)
> 
> 33(3 4 5)
> 
> 44(4 5)
> 
> 55(5)
> 
> NIL
> 
> it's a bug in lispworks?
> 
> With best regards, Alex Mizrahi.  E-mail: ·········@xhotmail.com
> 
> 

-- 
Tyler: "How's that working out for you?"
Jack: "Great."
Tyler: "Keep it up, then."
From: Jim Bushnell
Subject: Re: loop bug?
Date: 
Message-ID: <ro-dncJqXb6dHaLdRVn-gw@comcast.com>
"Alex Mizrahi" <·········@xhotmail.com> wrote in message
····················@ID-177567.news.uni-berlin.de...
> Hello, All!
>
> i found strange behaviour in Lispworks (4.2.0):
>
> (loop    for i from 0 to 5
>          for j in '(0 1 2 3 4 5)
>          and k on '(0 1 2 3 4 5)
>          do (format t "~A~A~A~%" i j k))
> 00(0 1 2 3 4 5)
> 11(0 1 2 3 4 5)
> 22(0 1 2 3 4 5)
> 33(0 1 2 3 4 5)
> 44(0 1 2 3 4 5)
> 55(0 1 2 3 4 5)
> NIL
>
> while Allegro does it like it's supposed to be:
>
> (loop for i from 0 to 5 for j in '(0 1 2 3 4 5) and k on '(0 1 2 3 4 5) do
> (format t "~A~A~A~%" i j k))
>
> 00(0 1 2 3 4 5)
>
> 11(1 2 3 4 5)
>
> 22(2 3 4 5)
>
> 33(3 4 5)
>
> 44(4 5)
>
> 55(5)
>
> NIL
>
> it's a bug in lispworks?
>
> With best regards, Alex Mizrahi.  E-mail: ·········@xhotmail.com
>
>

In this code, if one uses "for k on '(0 1 2 3 4 5)" instead of "and k on '(0
1 2 3 4 5)", the behavior is correct.

Looking at the hyperspec entry for loop, there are the items:

with-clause::= with var1 [type-spec] [= form1] {and var2 [type-spec] [=
form2]}*
for-as-clause::= {for | as} for-as-subclause {and for-as-subclause}*

It appears that there is in fact a bug in Lispworks (I use 4.3.6), but
avoiding 'and' and using 'for' instead is I think equivalent, and gives the
expected result.

Jim Bushnell