On Sun, Sep 25, 2005 at 11:24:05 -0700, Ashley Winters wrote: > 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!!!
If you say my $pet = Dog.new; if ($condition) { $pet = Cat.new; } my Car $spot = $pet; Then $pet's type is inferred to Cat|Dog, and must be able to contain either of those, but that is still not a Car. I'm assuming under use optimize where everything is closed.; > 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: That's the point of my question - why? What do I lose by inferrencing? -- () Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418 perl hacker & /\ kung foo master: /me climbs a brick wall with his fingers: neeyah!
pgp3QAv9ISVCF.pgp
Description: PGP signature