On Thu, Apr 24, 2008 at 1:20 AM, Ph. Marek <[EMAIL PROTECTED]> wrote:
> 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().
If you are certain to want a number then you either need to say
$a = +("100");
or use +($a) when passing it.
The most important skill a programmer can have is the ability to read.