Operator precedence bug?

From: Warwick Harvey <wh_at_icparc.ic.ac.uk>
Date: Thu 15 Nov 2001 02:47:32 PM GMT
Message-ID: <20011115144732.C1287@tempest.icparc.ic.ac.uk>
Hi,

There seems to be a precedence bug with respect to unary minus.  According
to the documentation, unary minus should have precedence 500, on par with
binary additive operators.  In particular, it should have lower precedence
than multiplication (400) and exponentiation (200).  But this is not the
case:

[eclipse 4]: X = -3*2, X =.. L.

X = -3 * 2
L = [*, -3, 2]
Yes (0.00s cpu)
[eclipse 5]: X = -2^9, X =.. L.

X = -2 ^ 9
L = [^, -2, 9]
Yes (0.00s cpu)

And it's not just that the minus is just being incorporated into the
integer, either:

[eclipse 6]: X = - 2 ^ 9, X =.. L.

X = -2 ^ 9
L = [^, -2, 9]
Yes (0.00s cpu)
[eclipse 7]: X = -(2)^9, X =.. L.

X = (-(2)) ^ 9
L = [^, -(2), 9]
Yes (0.00s cpu)

Parentheses also seem to have an effect:

[eclipse 4]: X = -Y^9, X =.. L.

Y = Y
X = -(Y ^ 9)
L = [-, Y ^ 9]
Yes (0.00s cpu)
[eclipse 7]: X = -(Y)^9, X=..L.

Y = Y
X = (-(Y)) ^ 9
L = [^, -(Y), 9]
Yes (0.00s cpu)


Cheers,
Warwick
Received on Thu Nov 15 14:47:33 2001

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:08:11 PM GMT GMT