in reply to Re^8: eval order of args to a sub
in thread eval order of args to a sub

Operation evaluation order is about precedence, operand evaluation order is about associativity

Precedence is about the order of evaluation of different operators.
Associativity is about the order of evaluation of operators with the same precedence.
While associativity seems to imply operand evaluation order, that's just an unfounded assumption.

Replies are listed 'Best First'.
Re^10: eval order of args to a sub
by shmem (Chancellor) on Jun 05, 2007 at 09:49 UTC
    You are both right, mrpeabody and ikegami - it's not in the specs; but my take on this is that in the expression
    $result = 8 - 4 - 2;

    the term 8 - 4 is a subexpression and the operand for the rightmost substraction operation; from that I deduce that associativity therefore defines the operand and subexpression evaluation order.

    That might be a logical fallacy; which one, I wonder?

    Anyways, that's how perl does it, although it is not defined in Perl. Of course the implementation could change, and perl could do a breadth-first evaluation of its execution tree and roll a dice for ad-hoc definition of evaluation order. But the optimizer would set things straight again, I guess :-)

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}