Phil Deets wrote:
On Thu, 01 Oct 2009 12:53:46 -0500, Andrei Alexandrescu
<[email protected]> wrote:
interface Comparator(T)
{
int opCmp(Comparator!T rhs);
mixin(Impl) // for each implementation Impl
{
int opCmp(Impl rhs);
override int opCmp(Comparator!T rhs)
{
return opCmp(cast(Impl) rhs);
}
}
}
I like that you can use this in interfaces too. It seems to allow for
something similar to multiple inheritance, but presumably without the
implementation difficulty.
Phil Deets
That's a great point. To compare this feature with Scala's mixins (which
I studied and now feel are a good feature), my understanding is that
Scala mixins are an interface plus a default implementation. The feature
proposed above is an interface with a prescribed implementation. That
way, Scala mixins seem to be somewhat more flexible.
Andrei