in reply to Re: Re: Incrementing a Hash Value
in thread Incrementing a Hash Value

Proof by experimentation's not valid for programming languages. Bad, bad idea. (This isn't physics here--the rules of the universe are subject to change from version to versions) Only what the standard, or the documentation, guarantees is valid to count on. Everything else should be considered a quirk of the implementation.

This bit, in particular, could easily be changed with a small cahnge to the optimizer, or optree generator. That it hasn't happened is mainly because nobody's bothered. (Well, because that part of the code's reasonably scary) Because of the way that perl works internally, both the pre and post increment versions of that code could easily resolve to 6.

Trust Abigail here. Don't count on the behaviour of multiple manipulations to a variable without an intervening sequence point.

Replies are listed 'Best First'.
Re: Re: Re: Re: Incrementing a Hash Value
by Juerd (Abbot) on Jun 14, 2002 at 19:15 UTC

    Only what the standard, or the documentation, guarantees is valid to count on. Everything else should be considered a quirk of the implementation.

    Shouldn't there be a lot more documentation, then? Increments and decrements are not the only things being documented vaguely.

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

      Yep, there should be, or at least more specific docs on how things should act. Perl is awfully fuzzy about the behaviour of a lot of things. (Witness the fact that perl only recently nailed down the behaviour of numeric operations)

      As a for example, in this:

      $a = $a + $a++;
      what should $a equal at the end? And if $a is tied or overloaded, what order should the tie/overload stuff be called in?