Many times the programmers use a few parenthesis to save code, however this is error-prone at operator precedence, a good concrete example I found was for Unpaws project made in Pascal, where the unary logic "not" operator has more precedence over the Set than the enumeration.
Fix diff patch:
530c530
< else if not (c in[6,13,16,17,18,19,20,21,22,23]) then inc(XPos);
---
> else if not c in[6,13,16,17,18,19,20,21,22,23] then inc(XPos);
Also from A Programmer's Guide to Java Certification, Second Edition says respect to unary operators: ``Expressions where variables are modified multiple times during the evaluation should be avoided, because the order of evaluation is not always immediately apparent.'' p.64
No comments :
Post a Comment