>Yes, but for `while`, the pattern isn't complete. The `setq` inside the
>loop is a crucial part:
>
>```
>(let ((a (foo ...)))
> (while a
> (do-stuff-with a)
> (setq a (foo ...))))
>```
>
>So the idea is that you want to test the result of some expression on each
>iteration. `while-let` basically lets you type that expression only once,
>instead of twice.
>
>At least that's how I understand `while-let`.
I understand; I think that was what Yuri also says. However, in that case,
how would one differ setup or initialization from evaluation in each iteration?
If all bindings are cleared and re-evaluated, than the user can not change
the loop invariants from within the loop without setting them elsewhere
outside the loop? I think it is also in a way setting them twice, and they are
no longer lexically enclosed.
The naive-version does ask the user to type that "last setq" manually.
Från: Joost Kremers <joostkremers@fastmail.fm>
Skickat: den 9 november 2024 22:47
Till: arthur miller <arthur.miller@live.com>
Kopia: Yuri Khan <yuri.v.khan@gmail.com>; emacs-devel@gnu.org <emacs-devel@gnu.org>
Ämne: Re: Sv: Is this a bug in while-let or do I missunderstand it?
On Sat, Nov 09 2024, arthur miller wrote:
> If it wasn't clear, the unintuitive part is that while-let was to
> establish the local environment, so that we don't need to type:
>
> (let ((som-var (init-form)))
> (while some-var
> ... ))
>
> At least is how I understand the purpose of if-let, when-let and while-let.
Yes, but for `while`, the pattern isn't complete. The `setq` inside the
loop is a crucial part:
```
(let ((a (foo ...)))
(while a
(do-stuff-with a)
(setq a (foo ...))))
```
So the idea is that you want to test the result of some expression on each
iteration. `while-let` basically lets you type that expression only once,
instead of twice.
At least that's how I understand `while-let`.
--
Joost Kremers
Life has its moments