In math, -x² is -(x²), not (-x)². But as proposed for JS, -x**2 is (-x)**2.
PHP, Python, Haskell, and D side with the traditional algebraic
notation, against JS. Here's PHP:
$ php -r 'print(-2 ** 2);'
-4
Python:
>>> -2 ** 2
-4
Haskell:
Prelude> -2 ^ 2
-4
The D grammar: http://dlang.org/grammar.html#UnaryExpression
Let's switch.
Another case to think about is `-2 ** -2`. In Haskell, that's a syntax
error, but the other three languages all treat it the same way, so
maybe JS should follow suit.
-j
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss