Exponentiation operator precedence
allen at wirfs-brock.com
Tue Aug 25 15:49:13 UTC 2015
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.
More information about the es-discuss