[tz] logical and arithmetic ops and operator precedence.

Paul Eggert eggert at cs.ucla.edu
Mon Oct 28 04:44:16 UTC 2019

On 10/27/19 6:39 PM, Christos Zoulas wrote:
> can we put parentheses around the operation for clarity?

I don't see how parentheses would help much in the expression here:

		if (lotm_ok & tm_ok
		    ? (delta(&tm, &lotm) == t - lot
		       && tm.tm_isdst == lotm.tm_isdst
		       && strcmp(abbr(&tm), ab) == 0)
		    : lotm_ok == tm_ok) {

It should be reasonably obvious even to a naive reader (who doesn't know that & 
has higher precedence than ?:) that the first line contains a subexpression. 
Although we could parenthesize it, just as we could parenthesize the 
subexpressions in each of the other lines for the benefit of naive readers, the 

		if ((lotm_ok & tm_ok)
		    ? ((delta(&tm, &lotm) == t - lot)
		       && (tm.tm_isdst == lotm.tm_isdst)
		       && (strcmp(abbr(&tm), ab) == 0))
		    : (lotm_ok == tm_ok)) {

is arguably a bit harder to read than the original, at least for people who know 
C syntax - which is the intended audience here.

More information about the tz mailing list