On 9/25/05, Yuval Kogman <[EMAIL PROTECTED]> 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

Reply via email to