Exponentiation operator precedence
Allen Wirfs-Brock
allen at wirfs-brock.com
Wed Aug 26 19:34:45 UTC 2015
On Aug 26, 2015, at 9:09 AM, Mark S. Miller wrote:
> I don't get it. The conflict between
>
> * the history of ** in other languages,
> * the general pattern that unary binds tighter than binary
>
> seems unresolvable. By the first bullet, -2 ** 2 would be -4. By the second, it would be 4. Either answer will surprise too many programmers. By contrast, no one is confused by either -Math.pow(2, 2) or Math.pow(-2, 2).
>
An of course the history includes many very popular languages that chose to not include an exponentiation operator.
This is really a cost-benefits issue. Several of us have identified costs (complexity, cognitive, pedagogical, error hazards, etc.). What are the benefits of having such an operator? Are they sufficient to offset the cost of having it.
Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150826/2e44e7a4/attachment.html>
More information about the es-discuss
mailing list