Exponentiation operator precedence

Jason Orendorff jason.orendorff at gmail.com
Tue Aug 25 00:24:28 UTC 2015

On Mon, Aug 24, 2015 at 5:45 PM, Waldemar Horwat <waldemar at 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 precedence
> inversion.

Don't you think having `-x**2` mean the same thing as `x**2` is more
confusing? It seems like it will cause problems for the exact
programmers we are trying to help with this feature.

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 ** UnaryExpression

An expression using both `**` and unary `-` is then parsed right-associatively:

    -a ** -b ** -c ** -d
    means -(a ** (-(b ** (-(c ** (-d))))))


More information about the es-discuss mailing list