Whilst the evaluation order is undefined
The behaviour is even definable and consistant
Those two lines contradict each other.
perl -MO=Deparse,-p only shows you
precedenceorder, not evaluation order.
Take for instance
$a = $a ++ + $a ++;
The evaluation order might be:
- Fetch the value of $a, save a copy. (A)
- Increment the value and store it back in $a.
- Fetch the value of $a, save a copy. (B)
- Increment the value and store it back in $a.
- Add (A) and (B), store the value in $a.
But it also might be:
- Fetch the value of $a (A)
- Fetch the value of $a (B)
- Add (A) and (B), store the value in $a
- Increment (A), store it back in $a
- Increment (B), store it back in $b
The order of evaluation is UNDEFINED,
and therefore, the entire statement is has undefined
behaviour.
And yes, I know the argument, "If I run the program, it
always returns XXX". That doesn't say anything. The order
in which keys are returned from a hash is undefined as well.
If you write a program that inserts the numbers 1 to 100
in a hash, in that order, and then fetches the keys, you
will get the same order on each run of the program. Does
that mean the order is defined? No, because that fixed order
will no longer happen with 5.8.1. Then the order will differ
from run to run. And it's safe to introduce that in a
maintainance release, because the order in which keys are
returned is undefined, even if you think you can predict it.
Abigail
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.