On Thursday 24 April 2008 22:09, Larry Wall wrote:
> > That makes me think of another way to confuse people who don't really
> > know the difference between numbers and strings:
> >
> >    $x = "-100";
> >    $x++;
> >    say $x;  # prints -101, not -99.
> Interesting point.  At one time we had the increments autocoerce to Num
> if the Str looked like a number.  I don't recall why we removed that...
> but this seems like a good argument for reinstating it.  Would also
> solve the "10" -> 9 problem, for some definition of "solve".
> Ah yes, if I recall, the argument was what to do with strings that
> look like "123E42" when the E could be accidental.  I can imagine a
> filename "123.4e2.  Or "0xF00D".  But this now seems like a weaker
> argument than decrementing "10" or incrementing "-100".  So I think
> I'll probably reinstate the "looks like a number", at least for
> integers in decimal notation.  We've got to scan the string anyway
> to look for the final alphanumeric string anyway, so seeing if it's
> pure digits with optional '-' on the front would not be any more
> inefficient.

Do we still get to keep the current semantics if we specificially declare a 
string? e.g.

my Str $x = "-100";
say $x;  # prints -101

my $y = "-100";
say $y;  # prints -99


Reply via email to