Not defining order of evaluation leaves more possibilities open for optimalizations. Consider for instance the expression:
f ($a) + g ($a)
If you define an order of evaluation, it would probably be: Notice the twice fetching of $a. If the order of evaluation isn't defined, you can first fetch the value of $a twice. Even if you do fetch the value twice (instead of fetching it once and remembering the results), doing it before calling f() and g() could be a win due to an increased chance of cache hits. It will also give you the opportunity to evaluate sub expressions in parallel.

Last but not least, if the order of evaluation is defined, people will start writing code that depends on this. This will lead to fragile code, that will break if you swap the arguments of an otherwise symmetric operator.

Finally, I don't see how lazy evaluation and a defined order of evaluation combine to a happy programming language. Perl6 will have a defined order of evaluation, and have lazy evaluation. I wonder how Larry is going to pull off that one.

Abigail


In reply to Re: Order of operations, mutators, aliasing and whammies by Abigail-II
in thread Order of operations, mutators, aliasing and whammies by demerphq

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.