New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade!

Kiuhnm kiuhnm03.4t.yahoo.it
Thu Mar 1 06:00:26 EST 2012


On 3/1/2012 1:02, Xah Lee wrote:
> i missed a point in my original post. That is, when the same operator
> are adjacent. e.g. 「3 ▲ 6 ▲ 5」.
>
> This is pointed out by Kiuhnm 〔kiuhnm03.4t.yahoo.it〕 and Tim Bradshaw.
> Thanks.
>
> though, i disagree the way they expressed it, or any sense this is
> different from math.

They did not make up the terminology, if that is what you are saying. 
The concepts of left and right associativity are well-known and accepted 
in TCS (Theoretical CS).

If you change the terminology, no one will understand you unless you 
provide your definitions every time (and then they may not accept them).

Another way of saying that an operator is left-associative is that its 
parse tree is a left-tree, i.e. a complete tree where each right child 
is a leaf.
For instance, (use a monospaced font)
   1 + 2 + 3 + 4
gives you this left-tree:
       +
     +   4
   +   3
  1 2
while 1**2**3**4
gives you this right-tree:
   **
1    **
    2    **
        3  4

Aho, Sethi and Ullman explain it this way in "Compilers: Principles, 
Techniques and Tools":
"We say that the operator + associates to the left because an operand 
with plus signs on both sides of it is taken by the operator to its 
left. [...]"
And they also show parse trees similar to the ones I wrote above.

Kiuhnm



More information about the Python-list mailing list