in reply to Re: Use of the => operator
in thread Use of the => operator

Am I correct in assuming the reason for doing the numeric interpretation first is to be able to say  my %foo = ( 3+5 => "something");? Presumably if fat comma stringification came first, this would become a parse error.

Replies are listed 'Best First'.
Re^3: Use of the => operator
by Zaxo (Archbishop) on Aug 09, 2004 at 21:51 UTC

    That comes from the high precedence of '+' over '=>'.

    If stringification came first there would be no error; you'd wind up with the string '3+5' as a key, which is perfectly all right. Fat comma stringifies like qw, breaking on whitespace.

    $ perl -e'%foo = ("3+5", "something");print keys(%foo),$/' 3+5 $

    After Compline,
    Zaxo

      Doh! I talked myself out of believing that, somehow.

      Now, of course, the question is which way is better... I guess that could be a Meditation some day.

Re^3: Use of the => operator
by ysth (Canon) on Aug 09, 2004 at 22:38 UTC
    I don't see why you need to look for reasons for stringification to apply to things that are already valid constants. v-strings introduced a new class of these, and %foo = (v48 => "zero?"); suddenly changed meaning, so that a key of "0" was used instead of a key of "v48". This was "fixed" in 5.8.1 to restore the "v48"-behavior for backward compatilibity, but the 5.6-5.8.0 way (where v48 is "0") was actually more consistent.