On 12/02/2011 09:27 PM, Adam wrote:
So this pattern allows you to provide partial implementations of an
abstract, and use template specialization to provide a sort of
"multiple inheritance" rather than strict class definition /
extension. That's important in Scala because of the lack of multiple
inheritance (as I understand it).

Am I understanding this correctly - that the point of this approach is
to replicate composition by multiple inheritance?

You can do that, but templates provide you with a lot more power. Note that some of my examples cannot be expressed as nicely in terms of multiple inheritance. That is because they rely on the order in which the classes are composed. This is sometimes discouraged in Scala afaik. I think, because there the type of an object does not depend on the trait mixin order. (not an issue here)

Parameterizing on the base class has quite some applications, its applications in C++ even have an own wikipedia page:

http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern

Reply via email to