help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Precedence of for clauses in cl-loop


From: Plamen Tanovski
Subject: Re: Precedence of for clauses in cl-loop
Date: Fri, 07 Sep 2018 14:35:56 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Noam Postavsky <npostavs@gmail.com> writes:

> On 7 September 2018 at 03:08, Plamen Tanovski <pgt@tanovski.de> wrote:
>> gives error, beacuse the z part is executed before the y line:
>>
>> (cl-loop
>>  for x in (number-sequence 1 10)
>>  for y = (1+ x)
>>  for z in (elt (number-sequence 1 10) y))
>
> This example also gives an error:
>
> (cl-loop
>  for x in (number-sequence 1 10)
>  for z in (elt (number-sequence 1 10) (1+ x)))
>
> because a `for VAR in LIST' clause evaluates LIST just once before the
> loop starts.

But

(cl-loop
 for x on (number-sequence 1 10)
 for z in (elt (number-sequence 1 10) (car x)))

works fine, which means, x was assigned a value before the for z clause.

> The "treated sequentially" in the manual refers to the assignment of
> VAR.

That's what I don't understand. After a "for VAR in" clause VAR is not
assigned and available for the rest of the for clauses. Obviously "for in
(across, etc.)" behaves different than "for on" and other for clauses.
I've tested with SBCL and there seems to be the same issue.  

best regards

-- 
Plamen Tanovski



reply via email to

[Prev in Thread] Current Thread [Next in Thread]