- About Scala
- In the Enterprise
- Scala Community
- Language Research
- In the Press
- The Scala Team
- Scala's Prehistory
- Contact Us
- Learning Scala
- Tour of Scala
- Scala API
- Setup & Getting Started
- Programming Guides
- Other Guides
- Code Examples
- Scala Developers
'a class is aways linearized before ...'
Sat, 2010-12-04, 18:24
'Programming in Scala' (on p260) explains that,
a class is always linearized before *all* of its superclasses and
mixed in traits.
I never quite understood this at the time, and have just seen it
quoted in Fredrik Skeel Løkke's thesis on design patterns.
After a determined effort to understand, I now reckon it should say,
a class aways appears before its superclasses and mixed-in traits,
in the sequence resulting from its linearization.
From the worked example (Cat class), it looks as though the superclass
is in fact linearised first, followed by each mix-in in turn (from
left to right), and then the class itself is appended last. The
resulting list is then reversed.