I was testing something https://caub.github.io/misc/calculator, and I
didn't see how it would be a problem to have the precedence of ** higher
than unaries.

But at least I'm happy something like (2).pow(3) wasn't chosen.

Thanks anyway and sorry for discussing something already frozen in spec
anyway

2016-10-14 14:33 GMT+02:00 Cyril Auburtin <cyril.aubur...@gmail.com>:

> Ah, ok, a bit sad because all more scientific languages, and python too,
> all math books, all will use `-e^3` for meaning `-(e^3)` (^ or **), because
> it's just `-exp(3)` or `-pow(E, 3)`
>
> and `(-1)^n` otherwise, when we want to take the signs with.
>
> If you wanted to avoid any confusion you could have forbidden `2**2**3`
> too because it's not obvious it's right associative
>
> But ok, thanks for the explanation.
>
>
> 2016-10-14 14:05 GMT+02:00 Bergi <a.d.be...@web.de>:
>
>> Cyril Auburtin schrieb:
>>
>>> I would expect `-2**3` to return -8, or `-2**2 == -4`, since it should be
>>> like `-(2**3)`
>>>
>>
>> You would, others would not. -2 ** 2 clearly should return 4, shouldn't
>> it?
>>
>> Is there a reason for this restriction? Python does it `-2**3` fine
>>>
>>
>> Because of the ambiguity it has been decided to make it a syntax error if
>> the two operators are used together. If you want `-(2**3)`, you have to
>> write it like that, and if you want `(-2)**3` you have to write it
>> explicitly as well.
>> See https://esdiscuss.org/topic/exponentiation-operator-precedence for
>> the full discussion.
>>
>> - Bergi
>>
>> _______________________________________________
>> 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