[EMAIL PROTECTED] wrote:


First off, I'm going to pound on one of my deceased horses a bit:

Why not drop the sigil on things with declared types?
Then $foo keeps its status as Perl's Magic Autoconverting Wondertype
and without it, we know we aren't dealing with the PMAW and we
won't make mistakes based on thinking that we are.

With it, we still have to remember what types things are declared
as, so it becomes meaningless.

Thanks for listening.



> I'm pondering this being okay:
> 
>         my Num    $dec = 4.0;
>         my Int    $int = $dec;  # Num -> Int okay since 4.0 truncates to 4
>                                 #     with no(?) information lost

You have lost information.  You have lost one digit of precision.  That is
not
insignificant. Although that information is currently carried in STRING
types and not in FLOAT types.


> You'd have to do an explicit typecast (syntax left as an exercise).
> Given that most times when you try to use a reference as a string
> you're making a mistake, this shouldn't be a big deal.

This would be a nice thing to have a pragmata for, what hash refs 
stringify to.

 
> Now, here's an example of something that might be really annoying to
> get right.  Let's say localtime() returns a hash in Perl 6 (sensible).
> Let's also say that not only does it return the year, mday, hour, min,
> sec, etc... as integers, it also returns things like the name of the
> month, name of the day, etc...
> 
>         my %time = localtime;
>         # "Today is Monday, July 9, 2001"
>         printf "Today is %s, %s %d, %d", $time{qw(dow month mday year)};
> 
> What should the return signature of localtime look like?  Obviously it
> should return a hash, so that much checks out.  But each of the keys
> should be typed as well, String or Num.  It would be really, really
> annoying to have to set up the hash and all its keys just right so it
> can accept the return value from localtime.  Instead, perhaps Perl can
> simply imply its type from the declaration:
> 
>         my %time = localtime;   # %time's type declaration is implied by
>                                 #    localtime's return signature AT
>                                 #    COMPILE TIME!
>         %time = gmtime;         # ok, localtime and gmtime have the same
>                                 #    signature.
>         $time{mday}++;          # ok, $time{mday} is an Int
>         $time{mday} .= 'foofer' # *run-time error*  Implicit $time{mday}
>                                 #    Int -> String cast ok for the string
>                                 #    append, but trying to convert the
>                                 #    String "10foofer" back to an Int fails.


localtime would return a magic read-only hash reference.  the dow lookup
would be deferred until printf needs it and no sooner.  And if we don't
use %time again for anything else in the block, it doesn't even get
memoized.


> 
>         my $foo;                # *error* forgot to declare a type.
> 
> We could have Perl go through heroics to try and find $foo's first
> assignment and imply a type from that, but I think that will rapidly
> get Messy and Surprising.

        my $foo;                # PMAW
        my int count;           # an integer (maybe an automatic big-int)

        ...
        count = int($foo);      # redundant, it's implied, unless
                                # using strict of some kind
        ...
        $foo = count;           # legal too

if you insist that $ only means "there's only one of this" you have
made it completely meaningless.  The scalar sigil should be dropped
from strongly typed variables.



-- 
                                           David Nicol 816.235.1187
                   "Perl was born in downtown Hell!" -- Matt Youell

Reply via email to