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: Mattias Engdegård
Subject: bug#71120: 29.3; buglet in cl-loop
Date: Thu, 30 May 2024 11:25:46 +0200

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.

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






reply via email to

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