New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!
rweikusat at mssgmbh.com
Wed Feb 29 16:15:02 CET 2012
Xah Lee <xahlee at gmail.com> writes:
> A excerpt from the new book 〈Modern Perl〉, just published, chapter 4
> on “Operators”. Quote:
> «The associativity of an operator governs whether it evaluates from
> left to right or right to left. Addition is left associative, such
> that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result.
> Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3
> ** 4 first, then raises 2 to the 81st power. »
> LOL. Looks like the perl folks haven't changed. Fundamentals of
> serious math got botched so badly.
> Let me explain the idiocy.
> It says “The associativity of an operator governs whether it evaluates
> from left to right or right to left.”. Ok, so let's say we have 2
> operators: a white triangle △ and a black triangle ▲. Now, by the
> perl's teaching above, let's suppose the white triangle is “right
> associative” and the black triangle is “left associative”. Now, look
> at this:
> 3 △ 6 ▲ 5
> seems like the white and black triangles are going to draw a pistol
> and fight for the chick 6 there. LOL.
As the perlop manpage would have told you,
Operator associativity defines what happens if a sequence of the same
operators is used one after another
Since this is not the case in your example, it doesn't seem to be
applicable here. Also, the Perl I'm aware doesn't have 'white
triangle' and 'black triangle' operators and it also doesn't have
operators of equal precedence and different associativity. It can't,
actually, since there would be no way to evaluate an expression like
the mock one you invented above. Lastly, that something happens to be
in one way or another way in the completely arbitrary set of rules and
conventions commonly referred to as 'mathematics' (an essentially
outdated write-only programming language dating back to the times
when humans had to perform computations themselves) doesn't mean it is
of any relevance anywhere else just because of this, no matter how
dear it might be to lots of people.
More information about the Python-list