GNU bug report logs -
#71120
29.3; buglet in cl-loop
Previous Next
Reported by: Philippe Schnoebelen <phs <at> lmf.cnrs.fr>
Date: Wed, 22 May 2024 14:49:02 UTC
Severity: normal
Found in version 29.3
Done: Stefan Kangas <stefankangas <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Mattias Engdegård <mattias.engdegard <at> gmail.com> writes:
> Philippe Schnoebelen <phs <at> 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
This bug report was last modified 79 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.