On Fri, Dec 12, 2003 at 03:10:30PM -0800, Paul Hodges wrote: : Ok, wait a sec. Does that mean different references to the same critter : can have differing sets of aspects? : : my Dog $Spot; : my $doggie = Dog.new(); : my $meandog = \$doggie.as(AttackDog); : my $nicedog = \$doggie.as(LapDog); : if $me.away { : if $visitor.nephew { : $Spot = $nicedog; : } else { : $Spot = $meandog; : } : } : : Now, if I'm away and someone show up, I presume that if it's my nephew : then $Spot.seeVisitor() will invoke the LapDog role's .wag() method, : but otherwise I expect it to invoke the AttackDog role's .Bark() : method. I realize there are other ways to get here.... but would this : *work*???
We might be able to make it work, though as you say, there are other ways to get there, and the chances are that at least one of them will be a better way. Certainly when the Dog object's class is composed, it will have to do something about the conflicting .seeVisitor methods in the two roles. It might well be better to encode that choice as part of the dog's state rather than in the references to it. On the other hand, it might just fall out of our implementation that it does the right thing with typed references, if the method dispatch to the conflicting methods in the Dog class can have access to the reference types to break ties. : And btw, just a refresher on this "assigning a ref" thing -- would the : syntax have to change at *all*? Dunno. I don't see anything obviously wrong with it, but then I never could see very well... Larry