On Mon, Oct 22, 2001 at 04:21:32PM -0400, Aaron Sherman wrote:
> On Mon, Oct 22, 2001 at 08:25:21PM +0100, Piers Cawley wrote:
> 
> > > What REALLY worries me is that values that seem to be numbers, but are
> > > in fact garbage ARE going to screw my average up. I dare Perl6 to fix
> > > that for me.
> > 
> > It's not going to. Getting NaN as a result in this context should be a
> > *really* big clue that Perl's found some garbage that it didn't
> > understand. If you want to know where then CHECK YOUR VALUES.
> 
> You misunderstood me. Yes, you'll get NaN if your garbage happens
> to not look like a number. But, this can give me no more sense of
> security than I had before, since garbage that happens to look like
> a number will still work "correctly".

So ... what do we want Perl's default nummify behaviour to be?  Right
now it trys to be smart in that if your string looks like "0xab" or
"12e3", it'll gladly be converted to 171 and 12000 respectively.

I think I'd prefer Perl be generally stupid about how it converts
strings to numbers so that the string "0xab" would get converted to 0
and the string "12e3" would get converted to 12.  All other complex
behavior could be done via pragmata or the user could specify
themselves like so:

        sub operator:+($nomnum) {
           return $1            if $nomnum =~ /^(\d+)$/;
           return hex($1)       if $nomnum =~ /^(0x[0-9a-fA-F]+)$/;
           return oct($1)       if $nomnum =~ /^(0[0-7]+)$/;
           return bin($1)       if $nomnum =~ /^(0b[01]+)$/;
           return com($1)       if $nomnum =~ /^(\d+i)$/;
           return NaN;
        }

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to