emacs-devel
[Top][All Lists]
Advanced

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

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


From: Joost Kremers
Subject: Re: Sv: Is this a bug in while-let or do I missunderstand it?
Date: Sat, 09 Nov 2024 22:47:55 +0100

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



reply via email to

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