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

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

bug#48219: 27.1.90; CL-LOOP facility fails with hash tables


From: Stefan Monnier
Subject: bug#48219: 27.1.90; CL-LOOP facility fails with hash tables
Date: Sat, 02 Jul 2022 16:20:00 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Lars Ingebrigtsen [2022-07-02 13:24:36] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> Yes, that does seem wrong.
>>
>> Agreed, but I don't know what the code is supposed to do when `database`
>> is not-nil, so I can't even tell if the code is meaningful.
>
> (cl-loop
>  for database in nil
>  for aux = (message "databse: %S" database)
>  for entry being the hash-values of database
>  do (message "FOO %S" database))
>
> Hm...  Oh, yeah -- that's not really a meaningful loop statement, is it?

I think it's not because `database` is both a loop variables (i.e. one
that iterates over elements of something else) and one of the something
else over which we want to iterate.  So the only meaningful
interpretation I can see would be 2 nested loops, but the `loop` macro
is designed to make a single loop, not nested loops.

FWIW, I just tried it with `clisp` and it happpily expands it into
a single loop which does something weird (it sets up up a hash-table
iterator to operator over "the hash-table `database`" but at a time
where the `database` variable has not yet been initialized (i.e. it's
nil)).

> But since it's a meaningless loop, perhaps erroring out in the hash
> table case is fine, too?

I'm OK with erroring out if we can emit a meaning error message.

> Whew!  That was simple!

Occam's razor, man: it's all in the shave!


        Stefan "who doesn't shave"






reply via email to

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