CBFalconer wrote:
Mirsad Todorovac wrote:
Please don't hate me - while writting mirsad08.pas I came to this problem: line 14 with Boolean expression fails to compile (or I don't know Pascal syntax well enough). I reduced the example to the minimum at which problem still appears.
Changing ... AND (i<start OR i>endr) AND ... to ... AND ((i<start) OR (i<endr)) AND ... made it compile.
You are a victim of C-think. Pascal precedence is very simple: multiplication, addition, comparison. are the fundamental groups. When in doubt, parenthize. The results also read better.
In general I agree. But in this case I prefer C's precedence. `and' and `or' are applied to (in)equations in the vast majority of times, so they'd better have a precedence lower than comparisons, and you have to parenthesize the few cases where you actually want to compare the results of `and' or `or' (especially rare in non-Borland dialects which don't have bitwise `and' and `or').
(I know the argument considering `and' like a multiplication and `or' as an addition. But since mathematically the addition in GF(2) would be `xor', not `or', I don't give too much for it ...)
But we can't change it, anyway ...
Frank