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

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

bug#71120: 29.3; buglet in cl-loop


From: Andrea Corallo
Subject: bug#71120: 29.3; buglet in cl-loop
Date: Thu, 30 May 2024 09:14:24 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

Mattias Engdegård <mattias.engdegard@gmail.com> writes:

> Philippe Schnoebelen <phs@lmf.cnrs.fr> writes:
>
>> When I need a list of 100 random dice throws I write
>> 
>>      (cl-loop for i from 1 to 100 collect (random 6))
>> 
>> It compiles just fine.
>> 
>> If instead I use
>> 
>>      (cl-loop for _i from 1 to 100 collect (random 6))
>> 
>> then I get a compilation warning:
>> 
>>      foo.el:1:18: Warning: variable ‘_i’ not left unused
>
> Quite unfair that you have no a priori way of knowing whether your variable 
> name is actually the one that `cl-loop` uses for iteration or just one bound 
> for each iteration (as in `dotimes`).
>
> A sloppy reading of Common Lisp's `loop` spec, which we don't need to follow 
> since this isn't CL but we'd be fools to deviate too far from without a good 
> reason, didn't tell me anything.
>
> In particular nothing about whether the user is allowed to alter the variable 
> in order to change the iteration. For example, what should
>
>   (cl-loop for i from 1 to 100
>            when (= i 3) do (setq i 98)
>            collect i)
>
> return? Perhaps better not touch that.

If the spec doesn't say anything usually means it's left to the
implementors (IOW it's UB).

> Thus I don't think there's anything we really need to do here, do you?

I, for one, think the nicest option is the one SBCL (and I guess other
CL implementations) are using, that is to have 'i' 'ignorable', the
problem is that we don't support this at language level.

  Andrea





reply via email to

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