Interfaces without implementation are like a day without sunshine

P T Withington ptw at
Wed Oct 25 04:09:55 PDT 2006

On 2006-10-24, at 13:03 EDT, Dave Herman wrote:

>> overriding, then, yes, we have implemented mixins.  Using the   
>> definitions you cite, interfaces << traits << mixins.  Traits  
>> remove  state (and in some cases overriding) from mixins,  
>> interfaces remove  behavior from traits.  Or, looking at it  
>> another way, traits and
> No, traits and mixins are different language features with  
> different designs and trade-offs. It's not just about instance  
> variables. Traits can be combined in any order, and mixins are  
> combined in a programmer-specified order. This means that traits  
> buy you convenience that mixins don't have: they abstract over the  
> inheritance chain. Mixins, OTOH, avoid diamond import problems by  
> forcing the programmer to create a total order on composition.

Perhaps I am mistaken, but it seemed to me the reason that traits can  
be combined in any order is because traits explicitly disallow  
conflicting properties.  (Either they are disallowed altogether, or  
they have to be renamed.)  This is what I meant by 'traits remove  
overriding from mixins'.

>> interfaces take power away from the programmer in the belief that  
>> the  programmer will only hurt themselves.  Where does es4 want to  
>> stand?
> This false dichotomy is trotted out all too often. Limiting the  
> expressive power of a programming construct has many purposes, and  
> "protecting novices" need not have anything to do with it.

My reading of Schärli, et al. is that traits are explicitly designed  
to remove features of multiple-inheritance and mixins that are deemed  
dangerous (because they lead to ambiguities and fragility).  Am I  
mistaken there also?

> But that's not even the issue: traits and mixins each have relative  
> pros and cons. It's an active research topic, and the final word  
> has not yet been written. Unfortunately, we're on a schedule and it  
> looks like this one is just out of scope.

I admit that I am out of the academic loop here.  If you can point me  
to additional reading, I'd appreciate it.

More information about the Es4-discuss mailing list