New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!
anikom15 at gmail.com
Fri Mar 2 01:46:52 CET 2012
First of all:
On Wed, Feb 29, 2012 at 12:09:16AM -0800, Xah Lee wrote:
> Now, let me tell you what operator precedence is. First of all, let's
> limit ourselfs to discuss operators that are so-called binary
> operators, which, in our context, basically means single symbol
> operator that takes it's left and right side as operands. Now, each
> symbol have a “precedence”, or in other words, the set of operators
> has a order. (one easy way to think of this is that, suppose you have
> n symbols, then you give each a number, from 1 to n, as their order)
> So, when 2 symbols are placed side by side such as 「3 △ 6 ▲ 5」, the
> symbol with higher precedence wins. Another easy way to think of this
> is that each operator has a stickiness level. The higher its level, it
> more sticky it is.
You're absolutely correct.
> the problem with the perl explanations is that it's one misleading
> confusion ball. It isn't about “left/right associativity”. It isn't
> about “evaluates from left to right or right to left”. Worse, the word
> “associativity” is a math term that describe a property of algebra
> that has nothing to do with operator precedence, yet is easily
> confused with because it is a property about order of evaluation. (for
> example, the addition function is associative, meaning: 「(3+6)+5 =
You're not getting it.
Math is a language. Perl is a language. They have different rules for
grammar. In Perl, C, Python, Java, and pretty much all procedural-based
languages, operations are evaluated in two steps: the precedence /and/
the associativity. Each level of precedence has its own associativity,
either left-to-right or right-to-left. You can see this in table 2-1 in
The C Programming Language. Whatever math does or what you think math
does has nothing to do with the way Perl evaluates expressions.
More information about the Python-list