Paul Eggert <[email protected]> wrote: > On 4/6/22 00:04, [email protected] 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. Thanks, Arnold
