develooper Front page | perl.perl6.language | Postings from September 2005

Re: Allomopherencing

Thread Previous | Thread Next
From:
Ashley Winters
Date:
September 25, 2005 11:24
Subject:
Re: Allomopherencing
Message ID:
cda42dbb0509251124feeee5c@mail.gmail.com
On 9/25/05, Yuval Kogman <nothingmuch@woobling.org> wrote:
> Hmm... Making up these subjects is fun =)

Very interesting. :)

> Under strict type inferrencing, i'd expect this to be a compile time
> error:
>
>         my $dog = Dog.new;
>
>         if ($condition) {
>                 my Cat $c = $dog;
>         } else {
>                 ...
>         }
>
> since it's guaranteed to be a runtime error if $condition is ever
> true.

I can't accept that. While you can infer that $dog will be a Dog at
that line of code, it isn't being enforced, which means no
compile-time error. $dog is allowed to store any kind of data, and you
only know what methods exist in Dog at compile-time. After all, I was
planning to add a &Dog::as(Cat) method at runtime. Yes, I'm a mad
scientist. Muahahaha!!!

In order to enforce that level of compile-time type safely, you should
need to declare my Dog $dog, or stick a pragma up top: use sadistic
<inferencing>; either of those declarations can disregard my potential
for runtime tomfoolery, and abort the compiliation when there's
something illogical.

Ashley Winters

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About