Re: RFC 218 (v1) C<my Dog $spot> is just an assertion
[email protected] (Nathan Wiger) Wed, 13 Sep 2000 18:18:26 -0700
| Newsgroups | perl.perl6.language.objects |
|---|---|
| Message-ID | <[email protected]> |
Nathan Torkington wrote: > > Yes! I mentioned the hypothetical > use strict 'types'; > which would require all variables assigned to/from an object, and > all variables upon which method calls are made, to be typed like > this. Then the compiler can: > (a) optimize > (b) check at compile-time Hate to add a "me too", but I think this is a great idea. Nat needs to be able to torture himself in whatever sick C-type ways he desires. ;-) ;-) Seriously, though, this adds lots of potential benefits. > Polymorphic > types also becomes a problem: how to say that it's okay for a variable > to hold a Dog *or* a Cat, because we know that both of them have a > "pet()" method? Seems in order to satisfy this you'd have to have a common ancestor, Pet, which Dog and Cat inherited: my Pet $foofoo; # Can be Dog, Cat, or anything inherited And if you didn't want inherited classes to count, you could specify that as an attribute: my Pet $foofoo : onlybase; # Must be a Pet, not Cat/Dog Or ":only", ":nochildren", ":justme", or any other similar word... -Nate