News for hackers. Stuff that matters.
Re:Tim Bray doesn't know operator precedence rules by barrkel on Wednesday June 30, 2010 @06:57AM (#1474441)
I would draw the line at additive, multiplicative operators generally, but I would also include &&, || and comparisons in C-derived languages (contra Tim). Knowing the extra three precedence levels is a cheap investment that covers such a wide range of commonly used languages - C, Java, C++, C#, bash's let/for/etc.

I don't think it's necessary to have to parenthesize:

    u*t + a*t*t / 2.0
Working with Pascal (Delphi) quite a bit as I do, I also find this idiom - required in Pascal with its limited number of levels - tedious:

    if (a > b) and (b < c) then // ...
The trouble is that you begin writing this:

    if a > b then
but updating it to add in the new conditional means you have to go back and forth over the expression inserting parentheses. I think C and related languages at the expression level make this better by making comparison operators have a higher precedence to boolean operators.

Bitwise operators, of course, have an entirely different precedence level and if you're using C, it's easy to get caught out:

    if (flags & MASK == FLAG1 | FLAG2) // cue much confusion
Re:Tim Bray doesn't know operator precedence rules by JoachimSchipper on Wednesday June 30, 2010 @04:12PM (#1476040)
I fully agree, but replace "much confusion" with "compiler warning".
Re:Tim Bray doesn't know operator precedence rules by barrkel on Friday July 02, 2010 @12:18PM (#1481498)
The only compiler I use that will warn for it is gcc, and even then you need to use -Wall.