On Thu, 15 Jul 2010, Zefram wrote: > David Golden wrote: > >Again, from perlop: > > > > Operator precedence means some operators are evaluated before others. > > For example, in "2 + 4 * 5", the multiplication has higher precedence > > so "4 * 5" is evaluated first yielding "2 + 20 == 22" and not "6 * 5 == > > 30". > > In that expression, the * operation does have to be performed before the > + operation. This does not imply anything about the order in which 2, > 4, and 5 are evaluated (which would matter if they were expressions with > side effects). And that is also what Perl currently does: $ perl -E 'sub AUTOLOAD { say $AUTOLOAD; ++$i } say a() + b() * c()' main::a main::b main::c 7 So it does call a() first, even though the multiplication of b() and c() happens before the result is added to a(). But there is nothing in the operator precedence description that would forbid Perl from delaying evaluation of a() until after b() * c() has been computed. Cheers, -JanThread Previous | Thread Next