[squeak-dev] Re: My view on Traits
Klaus D. Witzel
klaus.witzel at cobss.com
Sat May 17 09:30:13 UTC 2008
On Sat, 17 May 2008 10:12:47 +0200, Andreas Raab wrote:
> Klaus D. Witzel wrote:
>> I think you can easily judge for yourself whether or not a system gives
>> you multiple inheritance (MI):
>> o in Smalltalk every class has at most one superclass
>> o every MI class has at least two superclasses
>> o in Smalltalk a method can send to self or super
>> o a method in an MI class can choose to which super it sends
>> Compare Squeak's traits to these statements ...
> I don't think this is a particularly good definition of MI but the above
> certainly applies to traits: When a class uses a trait it certainly has
> multiple superclasses for all its observable behavior;
Sure, one can view it like that indeed (in particular *if* Trait *would*
inherit from ClassDescription ;)
> when the method in the trait is changed the behavior in the class
> changes unless it has been reimplemented locally, which is the behavior
> of superclasses.
> For the "super sends" the only reason for aliasing in traits that I'm
> aware of is to get access for a trait user to a "particular version of
> the superclass method". Even in the earliest papers there was an example
> about a "colored rectangle" derived from TColor and TRectangle used
> aliases to get to specific implementations in its "super classes".
Right. To be able to mimic "which super is meant" one has to carefully
handcraft composition rules and invent aliases in order to arrive at a
conflict-free situation (hopefully maintainable by the next hacker/user ;)
And since a user (*and* its superclasses) can have own methods,
conflict-free can mean cause of conflicts from both sides.
This (potential usability/mutual influence) is one of the reasons that I'm
interested in Trygve's work on roles (i.e. arrive at traits which are
independent of potential users).
> In other words, even though it may be called a little differently, the
> concepts that you describe are all present. Which is why traits are
> generally treated as a form of MI.
Which is why it *can* be confusing ;)
> - Andreas
More information about the Squeak-dev