If -2 ** 2 returned me -4 in JS I would be confused.
JS is not a math language, it's a programming language. We have basic math
operations on its syntax and that's fine.
> In the same vein, you have `pow(1+1, 2) == 4` but `1+1 ** 2 == 2`,
because the latter is interpreted as `1+(1 ** 2)`.
Where is this going to? Am I supposed to read the `1+1 ** 2 == 2` is a
sugar for `pow(1+1, 2)`? that's not my reading.
Python does not follow a standard implemented in many different
implementations governed by different ppl and orgs. Any behaviour, even the
unexpected, becomes a feature, it's an easy field and canvas. I'm glad JS
aims for a consistent and unambiguous path, even if that can't make
everyone loving the syntax.
On Fri, Oct 14, 2016 at 11:09 AM, Claude Pache <claude.pa...@gmail.com>
> > Le 14 oct. 2016 à 16:52, Rick Waldron <waldron.r...@gmail.com> a écrit :
> > Python is also inconsistent:
> > >>> pow(-2, 2)
> > 4
> > >>> -2 ** 2
> > -4
> > >>>
> This is not inconsistency, but that follows from operator precedence rules
> (those used in mathematics, not in C).
> In the same vein, you have `pow(1+1, 2) == 4` but `1+1 ** 2 == 2`, because
> the latter is interpreted as `1+(1 ** 2)`.
> es-discuss mailing list
es-discuss mailing list