[squeak-dev] Re: My view on Traits

Andreas Raab andreas.raab at gmx.de
Sat May 17 08:12:47 UTC 2008


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; 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".

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.

Cheers,
   - Andreas



More information about the Squeak-dev mailing list