Point B is the key.

Point C is tricky. The assertion that "++$i was performed on first, then $i++" is misleading. The distinction would only be relevant for ++$i++ which is illegal in any case. In the expression $i++ + --$i neither Perl nor C make any promises about the order in which the two sub expressions are evaluated. The second paragraph of Section A7 in "The C Programming Language (second edition)" (the K&R C book) makes that absolutely clear in the case of C (and assists in understanding the issue in Perl):

"... unless the definition of an operator guarantees that its operands are evaluated in a particular order, the implementation is free to evaluate operands in any order."

On the basis of that statement alone any of your tests involving addition are spurious. In particular note (from the same paragraph as cited above):

"... the order of evaluation of expressions is, with certain exceptions, undefined, even if the subexpressions involve side effects." (emphasis added)

Your colleague is either lucky or experienced with the particular implementation you are using. Watch out for changes between versions, platforms, C compiler and compiler options - one day you are going to get bit, and it will be particuarly nasty to diagnose!

Update: clarified the absolute clarity


DWIM is Perl's answer to Gödel

In reply to Re: Auto Increment "magic" Inquiry by GrandFather
in thread Auto Increment "magic" Inquiry by brusimm

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.