HaloO, Jonathan Lang wrote:
class GenSquare does GenPoint does GenEqual { has Int $.side; method equal ( GenSquare $p --> Bool ) { return $self.GenPoint::equal($p) and $self.side == $p.side; } }
This is exactly what I don't want. Such an equal method needs to be written in each and every class the role GenPoint is composed into. This is what I call a burden instead of code reuse by means of role composition. But I guess our points of view are hard to reconcile. You and the current spec see the class having the final word whereas I think that the role takes over responsibility. This does not require a telepathic compiler. Simply giving priority to the role suffices. Having the role in charge nicely matches the fact that the guarantee of doing a role makes a stronger claim than being an instance of a class. Doing the role happens with objects from different classes. And now imagine that some classes implemented equality correctly and some don't. With my approach the chance for this is diminished to a correct class specific implementation that is required and used by the role. Regards, TSa. --