On 8 Sep 2001, at 10:44, Maurice Lombardi wrote:
What says the standard ?
The Extended Pascal standard, Section 6.8.1 "Expressions, General" says: "Operator precedences shall be according to five classes of operators as follows. The operator 'not' shall have the highest precedence, followed by the exponentiating-operators, followed by the multiplying-operators, the adding-operators and signs, and finally, with the lowest precedence, the relational-operators. Sequences of two or more operators of the same precedence shall be left associative." Section 6.8.3.1, "Operators, General" defines the types of operators mentioned above: exponentiating-operator = "**" | "pow" multiplying-operator = "*" | "/" | "div" | "mod" | "and" | "and_then" adding-operator = "+" | "-" | "><" | "or" | "or_else" relational-operator = "=" | "<>" | "<" | ">" | "<=" | ">=" | "in" So that means that unary minus has the same precedence as binary minus, which is lower than that of "pow". So: -2 pow 2 is evaluated as: -(2 pow 2) and so equals -4. GPC is correct. As an aside, these rules are a bit odd, in that: a = b and c = d is evaluated as: a = (b and c) = d rather than as the more likely intended: (a = b) and (c = d) (In Ada, by contrast, the logical operators "and", "or", and "xor" have the lowest priority, so the first expression is evaluated as shown in the third expression.) -- Dave