emacs-devel
[Top][All Lists]
Advanced

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

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


From: Joost Kremers
Subject: Re: Is this a bug in while-let or do I missunderstand it?
Date: Tue, 12 Nov 2024 13:45:50 +0100
User-agent: mu4e 1.12.7; emacs 29.4

Hi Eli,

Thanks for your comments. I'll take them into account and come up with a
second version.

One question though:

On Tue, Nov 12 2024, Eli Zaretskii wrote:
[...]
> This is too long a description.

I can cut it down, but:

>  For starters, I don't see the need to
> justify the existence of the macro (we don't do that for the others).

Currently, before the description of `if-let*`, the manual contains an
explanation of the reason why `if-let*` and friends exist:

```
It can be convenient to bind variables in conjunction with using a
conditional.  It's often the case that you compute a value, and then
want to do something with that value if it's non-@code{nil}.  The
straightforward way to do that is to just write, for instance:

@example
(let ((result1 (do-computation)))
  (when result1
    (let ((result2 (do-more result1)))
      (when result2
        (do-something result2)))))
@end example

Since this is a very common pattern, Emacs provides a number of macros
to make this easier and more readable.  The above can be written the
following way instead:

@example
(when-let* ((result1 (do-computation))
            (result2 (do-more result1)))
  (do-something result2))
@end example

There's a number of variations on this theme, and they're briefly
described below.
```

Since `while-let` is a bit more complex, I thought I'd add a similar
explanation for it. I can try and shorten it, but I gather you think it
should be removed altogether?

> Can we make this shorter and yet clear enough to improve what we have
> there now?

I'll do my best. :-)

-- 
Joost Kremers
Life has its moments



reply via email to

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