emacs-devel
[Top][All Lists]
Advanced

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

Sv: Is this a bug in while-let or do I missunderstand it?


From: arthur miller
Subject: Sv: Is this a bug in while-let or do I missunderstand it?
Date: Sat, 9 Nov 2024 13:03:26 +0000

>> (progn
>>   (while-let ((run t))
>>     (message "Running")
>>     (setf run nil))
>>   (message "out of loop"))
>>
>> It ends in infinite recursion. setf/setq have no effect on the lexical variable.
>
>Probably not infinite recursion but infinite loop.
>
>Why would you expect anything else? ‘while-let’ is documented as:
>
>    Bind variables according to SPEC and conditionally evaluate BODY.

What should I expect?

It does not says *read-only bindings*, it says bindings. Is it
unreasonable to store a value in an established lexical binding?

(progn
  (let ((run t))
    (while run
      (message "running")
      (setf run nil))
    (message "not running")))

That is what I expect while-let to be equivalent to. But in practice
introduced bindings are "read only" since the current implementation of
while-let throws out bindings on each iteration of while loop, which
results in bindings being reset.

If that was the intention, I think it is counterintuitive, but I doubt it is.

reply via email to

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