Herby Vojčík (2015-09-25T11:18:19.000Z)
Herby Vojčík wrote:
>
>
> Claude Pache wrote:
>>
>> I just wonder why it is important that unary binds tighter? For
>> instance, before I carefully studied the issue of this thread, I have
>> never expected that unary minus binds tighter than binary multiplication
>> operator in expressions like `-2*x` (although it does not matter in that
>> case).
>>
>> Making the parentheses mandatory here will be somewhat annoying in
>> perfectly reasonable expressions, where you usually don’t use
>> parentheses in real math notation., like:
>> ```
>> let s2 = - x**2 - y**2 - z**2 + t**2
>> ```
>
> I would overcome it and do not write the parens:
>
> let s2 = 0 - x**2 - y**2 - z**2 + t**2

An off-topic thought: Unary minus (and plus) are only used with numbers 
in JS. Why are they treated specially, not as hidden 0+x and 0-x, 
respectively? That would be logical (unary plus and minus would have 
same precendence as binary plus and minus).

> Writing mandatory parens here is ugly.
>
> In fact, I am surprised "-2" is unary minus with 2, I thought it is
> number -2. And similarly to Claude, I always read -x*y in math notation,
> that is, as -(x*y). Luckily, for multiplication it does not matter.
>
> Herby
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
d at domenic.me (2015-10-12T20:23:42.039Z)
An off-topic thought: Unary minus (and plus) are only used with numbers 
in JS. Why are they treated specially, not as hidden 0+x and 0-x, 
respectively? That would be logical (unary plus and minus would have 
same precendence as binary plus and minus).