On Mittwoch, 23. April 2008, Larry Wall wrote:
> On Wed, Apr 23, 2008 at 04:03:01PM +0100, Smylers wrote:
> : The algorithm for increment and decrement on strings sounds really good,
> : however I'm concerned that dealing with all that has made the common
> : case of integer decrement a little less intuitive where the integer
> : happens to be stored in a string, for example in this case:
> :
> :    perl -wle '$a = 10; $b = shift; $a--; $b--; print "$a $b"' 10
> :
> : Perl 5 prints "9 9", but Perl 6 will print "9 09".
>
> On the other hand, "09" has the advantage of still having the numeric
> value 9.  But the converse is not true if the user was expecting a
> string decrement, since decrementing "10" in Perl 5 to get 9 is also
> counterintuitive if you were expecting "09".  So Perl 5 just punts,
> which is the third option.  In any case, there's always something
> to explain to a beginner.  But I think in Perl 6 we're leaning more
> toward preserving information than Perl 5 did.
But that doesn't really work for loops.

Imagine (excuse my perl5)
        $a = "100";
        $a-- for(1 .. 40);

So ($a eq "060")?
Then you'll have the problem that this gets (or might get) interpreted as 
octal somewhere; if not in perl6 directly (because of different base 
specifications), you're likely to get problems when passing that to other 
programs, eg. via system().


I think that's a can of work, and I'd be +1 on TSa:
> If the programmer really wants to decrement "10" to "09" she has 
> to cast that to Str: ("10" as Str)--. So we have "10".HOW === Str
> but "10".WHAT === Num Str. 
Regards,

Phil

Reply via email to