emacs-devel
[Top][All Lists]
Advanced

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

Re: Anaphoric macros: increase visibility


From: Richard Copley
Subject: Re: Anaphoric macros: increase visibility
Date: Sat, 14 Jan 2017 04:13:20 +0000

On 14 January 2017 at 03:03, Noam Postavsky
<address@hidden> wrote:
> On Fri, Jan 13, 2017 at 9:30 PM, Rolf Ade <address@hidden> wrote:
>>
>> Michael Heerdegen <address@hidden> writes:
>>> We also already have `if-let' and `when-let' in "subr-x".  They are like
>>> `aif' and `awhen' but you specify "it" explicitly.
>>
>> Since you mention them ... I probably miss something obvious but from
>> looking at the documentation of if-let
>>
>>     (if-let BINDINGS THEN &rest ELSE)
>>
>> and of when-let
>>
>>     (when-let BINDINGS &rest BODY)
>>
>> I don't get, why there is a need for when-let?
>>
>
> Just like there is both `if' and `when', it's useful to have both
> `if-let' and `when-let'.
>

Rolf, `when' and `when-let' are macros that expand to the corresponding
`if' form without an ELSE, so strictly the `when' forms are redundant,
as you suggest. But they make the code easier and quicker to read
(and feel a little more natural to write), because you know the ELSE
is null without having to think about it. Finding the ELSE (if any) of
an `if' form can be quite a pain. The unusual indentation of the THEN
clause exists for the same reason, but it's a bit ugly, which is a
second (maybe less important) motivation for `when'.



reply via email to

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