Oh ok, right. I didn't intend to be that general. There are a few select places where execution order is defined. Your example of the RHS computing before the LHS isn't a good one because that part isn't well defined. That only matters where computing the LHS has some sort of external effect on a dependancy of the RHS. Of course, the RHS has to be executed before the assignment but the LHS also has to execute to find the lvalue for the assignment and its that part that can move around.

Anyhow, I think I'm clear on when I care about execution order - only when the sub-expressions in a statement depend on each other - say multiple shift statements: sub { ${ shift() } = shift }->( a, b ). In this case sassign wants the LHS as its last argument so the second shift runs first then the first shift and scalar dereference. Execution order matters here because a common element is being altered. Ah well.

perl -MO=Concise -e '@ARGV=qw(a b); ${shift()} = shift;' | Idealized optrees from B::Concise

leave enter nextstate aassign pushmark const a const b pushmark rv2av gv nextstate sassign shift rv2av gv rv2sv scope shift rv2av gv

In reply to Re: Re: Matching and order of evaluation by diotalevi
in thread Matching and order of evaluation by diotalevi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.