Exponentiation operator precedence

Thomas thomasjamesfoster at bigpond.com
Tue Aug 25 16:16:46 UTC 2015

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.


> On 26 Aug 2015, at 1:49 AM, Allen Wirfs-Brock <allen at 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 at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150826/39ceed4d/attachment.html>

More information about the es-discuss mailing list