[Top][All Lists]

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

Re: gawk-5.1.1 bug report

From: arnold
Subject: Re: gawk-5.1.1 bug report
Date: Wed, 06 Apr 2022 02:24:20 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Paul Eggert <eggert@cs.ucla.edu> wrote:

> On 4/6/22 00:04, arnold@skeeve.com wrote:
> > IMHO clear code beats saving a single branch
> Sure, but clarity also argues for "&" over "&&" here. Writing "f(x) && 
> f(y)" would incorrectly imply that it's important that f(y) should not 
> be evaluated when f(x) is false, an implication that is incorrect here. 
> Writing "f(x) & f(y)" tells the reader that both sides are safe to 
> evaluate and that they can be evaluated in either order, something I 
> found worth knowing when I read that part of the code.

Only because you have umpteen years of C programming. Most people
would wonder "Why is there a bitwise and here?" and not think of it
as a logical and.

I'll stick to my opinion that && is better here since we're doing
logical tests; the short-circuit nature of && is less important.

In addition, & for a logical test can be dangerous since any non-zero
value can be true.  Even though you're using bool functions, &&
guarantees a logical true/false instead of an accidental one.



reply via email to

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