So far, I like the idea of exponentiation having identical precedence to
unary `+`/`-`, and lower than the increment operators. That sounds like it
should work pretty well.

```
x ** y // x^y
-x ** y // -(x^y)
x ** -y // x^(-y)

++x ** y === (++x) ** y
x++ ** y === (x++) ** y
x ** ++y === x ** (++y)
x ** y++ === x ** (y++)
```

On Tue, Aug 25, 2015, 12:17 Thomas <thomasjamesfos...@bigpond.com> wrote:

> This may be of some relevance:
> https://en.wikipedia.org/wiki/Order_of_operations#Special_cases
>
> Exponentiation is clearly exponentially more complicated in terms of order
> of operations and precedence than other operators if the desire is to
> follow 'standard maths'. Otherwise, making Exponentiation behave
> differently in JavaScript to how it does elsewhere is going to be a
> constant source of bugs and needing parentheses just to get the desire
> behaviour negates the whole point of making it an operator vs a function.
>
> Thomas
>
> On 26 Aug 2015, at 1:49 AM, Allen Wirfs-Brock <al...@wirfs-brock.com>
> wrote:
>
>
> On Aug 25, 2015, at 8:11 AM, Mark S. Miller wrote:
>
> I think we should drop the feature. Given the conflict between
>
>
> * the history of ** in other languages,
>
> * the general pattern that unary binds tighter than binary
>
>
> any solution at this point will confuse many people. These confusions will
> not result in a confusing static rejection but in runtime behavior that
> *sometimes* violates expectations. I was all for adding ** to the language
> when it did not have these problems. But it does. The minor convenience it
> adds is not worth these costs. By contrast, no one is confused about the
> parsing of calls to Math.pow.
>
>
> When in doubt, leave it out.
>
>
> I've had the same reaction to this recent thread.  It seems like the
> functional form (Math.pow) is a much less confusing formulation for  use in
> JS expressions.
>
> It's interesting to note that while early "algebraic  languages" such as
> FORTRAN, Algol 60, BASIC, PL/I all had exponentiation operators the next
> couple generations of similar languages including Pascal, C, C++, Java, and
> C# do not. Each of those languages could have had an exponentiation
> operator but choose to exclude it.
>
> The utility of an  exponentiation operation may simply not be worth the
> complexity and potential for confusion it introduces into a language with a
> rich set of operators.
>
> Allen
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to