bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#67669: 29.1; Drop text suggesting using `and' to replace `if'


From: Xiyue Deng
Subject: bug#67669: 29.1; Drop text suggesting using `and' to replace `if'
Date: Thu, 07 Dec 2023 12:37:58 -0800
User-agent: Gnus/5.13 (Gnus v5.13)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Xiyue Deng <manphiz@gmail.com>
>> Cc: 67669-done@debbugs.gnu.org
>> Date: Thu, 07 Dec 2023 11:54:20 -0800
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> > Sorry, I don't understand what you mean by "guarding a side effect",
>> 
>> I was referring to whether we care about and use the result of the
>> statement/function call.  In `and' we do, in `if' we don't and we just
>> use the side effect.
>
> But that's not true.  'if' does return a value, and we do use it.
> Consider this random example:
>
>   (defsubst posn-area (position)
>     [...]
>     (let ((area (if (consp (nth 1 position))
>                   (car (nth 1 position))
>                 (nth 1 position))))
>       (and (symbolp area) area)))
>
> Here we bind 'area' to the value returned by 'if'.

Well if we use `if' with else then yes.  Actually as Drew pointed out
this suggestion makes more sense if we are comparing `and' and `when'
(a.k.a. if without else), but point taken.

>
>> As I was just trying to argue just "a bit", I won't be insisting either.
>> Thanks for listening, and let me close this.
>
> Thanks.

-- 
Xiyue Deng





reply via email to

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