Exponentiation operator precedence

2015-08-24 Thread Jason Orendorff
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:

Re: Exponentiation operator precedence

2015-08-24 Thread Waldemar Horwat
On 08/24/2015 17:24, Jason Orendorff wrote: On Mon, Aug 24, 2015 at 5:45 PM, Waldemar Horwat walde...@google.com wrote: Let's not. As I said at the last meeting, making ** bind tighter than unary operators would break x**-2. And making it sometimes tighter and sometimes looser would be too

Re: Exponentiation operator precedence

2015-08-24 Thread Jason Orendorff
On Mon, Aug 24, 2015 at 7:24 PM, Jason Orendorff jason.orendo...@gmail.com wrote: What you're describing as sometimes tighter and sometimes looser I would call the same precedence. It's even easier to specify than the current proposal: UnaryExpression : PostfixExpression **

Re: Exponentiation operator precedence

2015-08-24 Thread Jason Orendorff
On Mon, Aug 24, 2015 at 8:10 PM, Waldemar Horwat walde...@google.com wrote: That has different right and left precedence and is probably the closest to the mathematical intent. Not to quibble, but I do want to understand: UnaryExpression : PostfixExpression ** UnaryExpression

Re: Exponentiation operator precedence

2015-08-24 Thread Daniel Ehrenberg
On Mon, Aug 24, 2015 at 3:45 PM, Waldemar Horwat walde...@google.com wrote: On 08/24/2015 10:08, Jason Orendorff wrote: 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

Re: Exponentiation operator precedence

2015-08-24 Thread Jason Orendorff
On Mon, Aug 24, 2015 at 5:45 PM, Waldemar Horwat walde...@google.com wrote: Let's not. As I said at the last meeting, making ** bind tighter than unary operators would break x**-2. And making it sometimes tighter and sometimes looser would be too confusing and lead to other opportunities for