Re: [Fwd: Re: Numeric Literals (Summary)]
[email protected] Fri, 15 Nov 2002 12:10:38 +0200
| Newsgroups | perl.perl6.documentation |
|---|---|
| Message-ID | <[email protected]> |
Dave Whipp writes:
> Richard Nuttall wrote:
>
> > How about
> >
> > my $a = 256:192.169.34.76;
> > my $b = $a.base(10);
> > my $c = '34:13.23.0.1.23.45'.base(16);
>
> This coupling makes me nervous. A number is a number: its value is not
> effected by its representation.
>
> I can see that, in some scripts, it might be useful to define a property
> such that:
>
> my $a = 26 but string_fmt("%02x"); # == ("%16.02r")
> print $a, "$a", ~$a, sprintf("%s", +$a);
>
> would print "26 1a 1a 26" (without the spaces).
>
> However, I would not like to see such a property set by default. It has
> the potential to cause too many surprises for the unsuspecting recipient
> of a number, who suddenly finds it behaves in funny ways.
>
>
> Dave.
>
>
>
I agree, all that is just *stringification* of numeric values . since
programm is wriiten as string we have to have different formats of
*writing* numbers for perl to understand us and correspoding formats
for perl to write numbers , for us to understand perl. so , e.g.
> > my $b = $a.base(10);
> > my $c = '34:13.23.0.1.23.45'.base(16);
is nonsence . base(16) have to be a property ( or argument ) to
stringification function.
$a = 10;
my str $str = str( $a : "base" => 16 );
my num $a = num( '13.23.0.1.23.45' : "base" => 34 )
arcadi