all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Plamen Tanovski <pgt@tanovski.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Precedence of for clauses in cl-loop
Date: Fri, 07 Sep 2018 14:35:56 +0200	[thread overview]
Message-ID: <20180907123556.41C883381CF@munka.dynalias.org> (raw)
In-Reply-To: CAM-tV--PEeDNsmHsRLOsVESxpXuFyhYoJutP=KfO901nxcowXw@mail.gmail.com

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	other threads:[~2018-09-07 12:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06 18:33 Precedence of for clauses in cl-loop Plamen Tanovski
2018-09-06 22:43 ` Noam Postavsky
2018-09-07  7:08   ` Plamen Tanovski
2018-09-07 11:16     ` Noam Postavsky
2018-09-07 12:35       ` Plamen Tanovski [this message]
2018-09-08  1:37         ` Noam Postavsky
     [not found]         ` <mailman.511.1536370625.1284.help-gnu-emacs@gnu.org>
2018-09-08 14:41           ` Udyant Wig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180907123556.41C883381CF@munka.dynalias.org \
    --to=pgt@tanovski.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.