[tz] logical and arithmetic ops and operator precedence.

Christos Zoulas christos at zoulas.com
Mon Oct 28 01:39:33 UTC 2019

That is fine and your preference usually produces shorter code (although I prefer "logical and" in a logical context and only use "bitwise and" in an arithmetic context),  
but can we put parentheses around the operation for clarity?



> On Oct 27, 2019, at 7:06 PM, Paul Eggert <eggert at cs.ucla.edu> wrote:
> On 10/27/19 2:53 PM, Christos Zoulas wrote:
>>                 if (lotm_ok & tm_ok
> ...
>>                 if ((lotm_ok && tm_ok)
>> for clarity? Both lotm_ok and tm_ok are booleans...
> Plain AND is simple and goes pretty much all the way back to Boole, if not further. In contrast, short-circuit AND has dicey semantics and is a relative newcomer. Although it's awkward that C uses "&" for both plain and integer-bitwise AND, for booleans I mildly prefer "&" to "&&" when either will do, if only to remind readers of "&&"'s problems.

More information about the tz mailing list