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

192, Wow!

There is a good reason for leaving things undefined if there is some benefit in implementing the process in different ways. It seems to me that that was what happened in C.

The thing about C, and C++ today, is that the compilers branched off implementing the same standard (including its undefined components) individually.

Perl, onm the other hand is a unidirectional implementation, as far as I can tell. I don't think there are people out there defining their own aspects of perl and releaseing their own version, are there?

Perl is implemented in C, not by C, so perl does not suffer from the same "undefined" qualities that C does, unless there is a specific branched version of perl.

It may be the case that some past versions of perl exhibit different behaviour, in context, but is that bug or feature?

C specifically states this as undeifned. I think if perl did the same, your point would be valid. Otherwise, if the behaviour is differnt, then that means people are doing their own thing.

--
Steve Marvell

Replies are listed 'Best First'.
Re: Incrementing a Hash Value
by Abigail-II (Bishop) on Jun 14, 2002 at 16:49 UTC
    C specifically states this as undeifned. I think if perl did the same, your point would be valid.
    From man perlop
        "++" and "--" work as in C.
    

    Convinced?

    Abigail

      No, because I can actually read perlop and find the following information right in the next paragraph.
      The auto-increment operator has a little extra builtin magic to it. If you increment a variable that is numeric, or that has ever been used in a numeric context, you get a normal increment. If, however, the variable has been used in only string contexts since it was set, and has a value that is not the empty string and matches the pattern `/^[a-zA-Z]*[0-9]*$/', the increment is done as a string, preserving each character within its range, with carry: print ++($foo = '99'); # prints '100' print ++($foo = 'a0'); # prints 'a1' print ++($foo = 'Az'); # prints 'Ba' print ++($foo = 'zz'); # prints 'aaa'
      And that certainly doesn't look like the behavior of any C compiler I ever worked with!

      So it works  as in C except obviously where it doesn't.

        Perhaps you should look up the meaning of extra in a dictionary.

        Abigail

      That is, if placed before a variable, they increment or decrement the variable before returning the value, and if placed after, increment or decrement the variable after returning the value."

      I don't think that's in the same spirit, do you?

      --
      ¤ Steve Marvell