On Thu, Jul 15, 2010 at 10:06 AM, David Golden <xdaveg@gmail.com> wrote: > On Thu, Jul 15, 2010 at 9:33 AM, demerphq <demerphq@gmail.com> wrote: > >> On the other hand, it may not be documented or specified, but I think > most > >> people would expect that in the following, f() is called before g(): > >> $f() . $g() > > > > Hmm. I don't know that I would. If we want this to be the case then > > IMO we should document it. > > I thought this was actually specified in terms of precedence and > associativity, but if I read it narrowly as written, it's not. At > best it's implied. > Operand evaluation order is only specified for some operators. It's has nothing to do with precedence or associativity (which is a tie breaker for precedence). Off the top of my head, it is documented for logical operators (to allow short circuiting), comma operator (to allow it to be used as a semi-colon) and the flip-flop operator. I also consider it defined for assignment operators (otherwise local $foo = $foo; wouldn't work) and for =~, But maybe we can get there by analogy with some identity operations. > Consider this: > > q{} . $f() . $g() > > Concatenation is left associative so C<< q{} . $f() >> is evaluated > first. So the left "." is evaluated first, but the following does not contradict the docs: $ST[0] = g(); $ST[1] = f(); $ST[2] = q{}; $ST[1] = $ST[2] . $ST[1] # left dot $ST[0] = $ST[1] . $ST[0] # right dot A function call has higher precedence so $f() is evaluated > before the concatenation. > Functions calls are not on the precedence table. They are considered terms (not operators) at the grammar level. - EricThread Previous | Thread Next