From: Jens Teich
Subject: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <uy7h4oo1c.fsf@jensteich.de>
This ...

CL-USER 1 > (loop for i for j in '(a b c) collect (cons i j))
=> ((0 . A) (1 . B) (2 . C))

works perfectly on LispWorks, but not with SBCL

=> FOR is an unknown keyword in FOR or AS clause in LOOP.

I found a way around it 'for i from 0' but am not sure if there is
another smarter way to achieve this.

Jens

-- 
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

From: ··@codeartist.org
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <1185359655.697750.151790@19g2000hsx.googlegroups.com>
On 25 Jul., 11:01, Jens Teich <····@jensteich.de> wrote:
> This ...
>
> CL-USER 1 > (loop for i for j in '(a b c) collect (cons i j))
> => ((0 . A) (1 . B) (2 . C))
>
> works perfectly on LispWorks, but not with SBCL
>
> => FOR is an unknown keyword in FOR or AS clause in LOOP.
>
> I found a way around it 'for i from 0' but am not sure if there is
> another smarter way to achieve this.

I think the canonical way would be

(loop for i upfrom 0
      for j in '(a b c)
      collect (cons i j))

ciao,
Jochen
From: Pillsy
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <1185365576.563161.49940@o61g2000hsh.googlegroups.com>
Jens Teich wrote:

> This ...

> CL-USER 1 > (loop for i for j in '(a b c) collect (cons i j))
> => ((0 . A) (1 . B) (2 . C))

> works perfectly on LispWorks, but not with SBCL

> => FOR is an unknown keyword in FOR or AS clause in LOOP.

It looks like LispWorks is being more tolerant than it needs to be.
According to the CLHS[1], you need to have at least one preposition
after the variable name in arithmetic stepping clauses.

> I found a way around it 'for i from 0' but am not sure if there is
> another smarter way to achieve this.

That's probably the easiest way to go. There are dozens of others,
though. For example:

(let ((count 0))
  (mapcar (lambda (elt)
	    (prog1
		(cons count elt)
	      (incf count)))
	  '(a b c)))

Cheers,
Pillsy

[1] http://www.lisp.org/HyperSpec/Body/sec_6-1-2-1-1.html
From: Slobodan Blazeski
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <1185371314.066116.307410@22g2000hsm.googlegroups.com>
On Jul 25, 2:12 pm, Pillsy <·········@gmail.com> wrote:
> Jens Teich wrote:
> > This ...
> > CL-USER 1 > (loop for i for j in '(a b c) collect (cons i j))
> > => ((0 . A) (1 . B) (2 . C))
> > works perfectly on LispWorks, but not with SBCL
> > => FOR is an unknown keyword in FOR or AS clause in LOOP.
>
> It looks like LispWorks is being more tolerant than it needs to be.
> According to the CLHS[1], you need to have at least one preposition
> after the variable name in arithmetic stepping clauses.

Indeed take for example :
LW
CL-USER 1 > (loop for i downto -10 collect i)
(0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10)
& Allegro
CG-USER(1):  (loop for i downto -10 collect i)
Error: Don't know where to start stepping.
Current LOOP context: FOR I DOWNTO -10 COLLECT.
[condition type: PROGRAM-ERROR]

Makes your life easier but non-portable better avoid such things.
From: Alex Mizrahi
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <46a75fdc$0$90275$14726298@news.sunsite.dk>
(message (Hello 'Jens)
(you :wrote  :on '(Wed, 25 Jul 2007 11:01:03 +0200))
(

 JT> CL-USER 1 > (loop for i for j in '(a b c) collect (cons i j))
 JT> => ((0 . A) (1 . B) (2 . C))

and, do you really like that code? is it readable?
if I encounter such stuff, i'd yell "WTF??".

 JT> I found a way around it 'for i from 0'

as others have noted, canonic way is to use upfrom. for i upfrom 0. 
perfectly readable and makes sense for anybody, even if they do not know the 
language.

JT> if there is another smarter way to achieve this.

what are you going to achieve, unreadable code? try DO then.

)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"scorn") 
From: Slobodan Blazeski
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <1185433330.525973.265840@l70g2000hse.googlegroups.com>
LOOP is already unlispy, making your code hard to read a locking
yourself with a certain vendor is a certain no no. maybe you should
try iterate, it has few more parens but you'll feel right at home.
http://common-lisp.net/project/iterate/
From: Pascal Costanza
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <5gr9fnF3h1f3vU1@mid.individual.net>
Slobodan Blazeski wrote:
> LOOP is already unlispy, making your code hard to read a locking
> yourself with a certain vendor is a certain no no. maybe you should
> try iterate, it has few more parens but you'll feel right at home.
> http://common-lisp.net/project/iterate/

Opinions on what is and isn't "lispy" vary enormously.


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Slobodan Blazeski
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <1185453101.605108.140970@b79g2000hse.googlegroups.com>
On Jul 26, 11:57 am, Pascal Costanza <····@p-cos.net> wrote:
> Slobodan Blazeski wrote:
> > LOOP is already unlispy, making your code hard to read a locking
> > yourself with a certain vendor is a certain no no. maybe you should
> > try iterate, it has few more parens but you'll feel right at home.
> >http://common-lisp.net/project/iterate/
>
> Opinions on what is and isn't "lispy" vary enormously.


"I saw the code for your computer program yesterday. It looked easy.
Its just a bunch of typing. And half of the words were spelt wrong.
And dont get me started on your over-use of parens."
        - The Pointy Haired Boss sees some actual code
From: Pascal Costanza
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <5grjfkF3i8go1U1@mid.individual.net>
Slobodan Blazeski wrote:
> On Jul 26, 11:57 am, Pascal Costanza <····@p-cos.net> wrote:
>> Slobodan Blazeski wrote:
>>> LOOP is already unlispy, making your code hard to read a locking
>>> yourself with a certain vendor is a certain no no. maybe you should
>>> try iterate, it has few more parens but you'll feel right at home.
>>> http://common-lisp.net/project/iterate/
>> Opinions on what is and isn't "lispy" vary enormously.
> 
> 
> "I saw the code for your computer program yesterday. It looked easy.
> Its just a bunch of typing. And half of the words were spelt wrong.
> And dont get me started on your over-use of parens."
>         - The Pointy Haired Boss sees some actual code

LOL

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Madhu
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <m3zm1ih9mt.fsf@robolove.meer.net>
* Pascal Costanza <··@p-cos.net> <···············@mid.individual.net> :
| Slobodan Blazeski wrote:
|> LOOP is already unlispy, making your code hard to read a locking
|> yourself with a certain vendor is a certain no no. maybe you should
|> try iterate, it has few more parens but you'll feel right at home.

I find the OP's suggestion paradoxical: he is suggesting ``lock on'' to
a _"a changing piece of open source software without an obligatory
specification"_ (Edi Weitz's words in ·············@agharta.de).
However LOOP is in the ANSI spec.  Learning to use it to correctly
conform to the spec would make your code most portable and less
suceptible to some (any) "vendor lock in".

| Opinions on what is and isn't "lispy" vary enormously.

I suspect people perceive adding parens makes it somehow makes it more
"lispy".  I find the extra syntax that iter adds to be actually less
lispy (iter (for ....)).  If truly "lispy" The `for' in functional
position would have `functional meaning'.  So iter also boils down to
"arbitrary" syntax implemented in the macro as an exercise in appealing
(pandering!) to the programmer's tastes, and nothing more.

--
Madhu
From: Slobodan Blazeski
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <1185527124.061067.296840@k79g2000hse.googlegroups.com>
Learning to use loop  correctly is definately good, even if you don't
like it you have to read code written by other programmers. Anybody
could try and see for itself what kind of iteration construct it finds
appropriate. As for lispy unlipsy it looks like that Pascal comment is
true even in a small thread like this,  so Jens learn to use loop
correctly and than check on iterate and series if they could fit your
idea of programming.
From: Jens Teich
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <uy7h2nfo0.fsf@jensteich.de>
Slobodan Blazeski <·················@gmail.com> writes:

> Learning to use loop  correctly is definately good, ...

That's what I did in this thread.

I first worked with Lispworks and used loop incorrectly. I didn't
notice my fault and was astonished when sbcl complained.

> ... so Jens learn to use loop ...

Thanks for this lecture.

Jens
From: Slobodan Blazeski
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <1185547118.829274.127450@q75g2000hsh.googlegroups.com>
On Jul 27, 3:23 pm, Jens Teich <····@jensteich.de> wrote:
> Slobodan Blazeski <·················@gmail.com> writes:
> > Learning to use loop  correctly is definately good, ...
>
> That's what I did in this thread.
>
> I first worked with Lispworks and used loop incorrectly. I didn't
> notice my fault and was astonished when sbcl complained.
>
> > ... so Jens learn to use loop ...
>
> Thanks for this lecture.

Don't take lectures from me, I'm far from lisp guru, only opinion. If
you really need one take the intro about loop in PCL, that is the
place where my example comes from, I worked through the chapter with
lw and wondered what Peter is trying to say, than I tried the same
with Allegro and got an error.
From: Jens Teich
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <utzrpongl.fsf@jensteich.de>
> [...] about loop in PCL [...]

Loop for blackbelts. Hm. My belts color is between white and green :)

Jens
From: Rainer Joswig
Subject: Re: SBCL complains where Lispwork does not: loop for i for j
Date: 
Message-ID: <joswig-FCF49A.19085427072007@news-europe.giganews.com>
In article <·············@jensteich.de>, Jens Teich <····@jensteich.de> 
wrote:

> Slobodan Blazeski <·················@gmail.com> writes:
> 
> > Learning to use loop  correctly is definately good, ...
> 
> That's what I did in this thread.
> 
> I first worked with Lispworks and used loop incorrectly. I didn't
> notice my fault and was astonished when sbcl complained.

Happens sometimes.

I recently compiled Maxima and LispWorks complained
about some code using LOOP.

The code was  (loop ... by #'some-macro ...)
LispWorks rightfully did not allow that. Some other
implementations compiled the code without
problem....

> 
> > ... so Jens learn to use loop ...
> 
> Thanks for this lecture.
> 
> Jens

-- 
http://lispm.dyndns.org