Ethan is making my point far better than I did, and I agree completely about the issue of unary operators visually appearing more tightly bound than binary operators.
At this point it seems fair to at least acknowledge the prospect of significant whitespace. ``` -x**2 === -(x ** 2) -x ** 2 === (-x) ** 2 ``` On Thursday, August 27, 2015, Steve Fink <sph...@gmail.com> wrote: > On 08/27/2015 11:20 AM, Ethan Resnick wrote: > >> Long-time esdiscuss lurker; hopefully this perspective is helpful. >> >> I think the problem here is that traditional mathematic notation uses >> visual cues to imply precedence that JS can't take advantage of. When -3 ** >> 2 is written out on paper, the 2 is very clearly grouped visually with the >> 3. In fact, the superscript almost makes the 2 feel like an appendage of >> the 3. That makes it more natural to read it as two items: the negative >> sign, and (3 ** 2). >> >> By contrast, when (-3 ** 2) is written out in code, the negative sign is >> way closer visually to the 3 than the 2 is, so I find myself instinctively >> pulling out a "-3" first and reading the expression as (-3)**2. >> > > If we're making ** bind tighter than unary -, then I would hope it would > be written -3**2, not -3 ** 2. The latter is indeed deceptive. > > For me, x**y**z is rare enough that I don't really care if ** is right > associative or nonassociative. Parentheses are part of the cost you have to > pay for rendering things as plain text -- and yet, I see no reason not to > make x**y**z just do the right thing. > > _______________________________________________ > 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