Interfaces without implementation are like a day without sunshine

Dave Herman dherman at
Tue Oct 24 07:03:21 PDT 2006

> Yes, we allow multiple inheritance of traits.  Our traits are the  same 
> as mixins, it just seems that trait is a more modern term

I'm pretty sure this is false. Both terms are used in current 
literature, and they are considered distinct. Naturally, there's a lot 
of variation in the usage of each, so there aren't "universal" 
definitions. But they aren't interchangeable, either.

According to Fisher and Reppy:

"Mixins are a mechanism designed to give many of the benefits of 
multiple inheritance in single-inheritance languages. There are strong 
similarities between traits and mixins, which are another mechanism 
designed to address code sharing in single-inheritance languages. The 
main difference between mixins and traits is that mixins force a linear 
order in their composition. This order avoids the complexities of the 
diamond property, but it makes mixins a more fragile mechanism."


Now, I have never seen traits with fields before. All the literature 
I've seen motivates traits as "pure units of behavior" and disallow 
instance variables. For example, according to Nierstrasz et al:

"Traits bear a superficial resemblance to mixins, with several important 
differences. Several traits can be applied to a class in a single 
operation, whereas mixins must be applied incrementally. Trait 
composition is unordered, thus avoiding problems due to linearization of 
mixins. Traits contain only methods, so state conflicts are avoided..."


Based on your description, it sounds like what you have implemented is 
order-sensitive and allows fields. So what you have sounds like mixins, 
not traits.


More information about the Es4-discuss mailing list