[Mono-list] Re: Resource System Proposal

Robert Deviasse rdeviasse@hotmail.com
Fri, 15 Feb 2002 16:32:41 -0500

> >  > In any case the CLR is designed to avoid that by making its 
>requirement of
> >  > multiply inherited classes be abstract, so if you want broken OO via 
> >  > Mixins, I wouldn't expect the CLR to ever support that. ILX would 
> >  > support the CLR notion of single inheritance, multiple interfaces.
> > > You're talking about interfaces, not mixins.  The term came from the
> > Flavors object system for Lisp, and mixins *do* come with
> > implementations.  They're little classes that aretn't terribly useful
> > by themselves, but when mixed in with a substantial class, add
> > functionality.
>Which from a modern OO perspective is a Very Bad Thing. Which is why
>neither Java nor C# support them.
>To achieve what you want without breaking encapsulation, use the
>decorator pattern. Again if refer to Gang of Four.

Actually, you're right that the decorator pattern allows you to emulate
the core mixin functionality with the decorator pattern, but you're
wrong about mixins having less encapsulation than the decorator
pattern. It's actually the other way around.

Mixins can be translated directly into C++ or Eiffel. A mixin is simply
templated inheritance plus the decorator pattern as the following link 

Before you comment that that the design would be cleaner if classes
like Person were inherited from interfaces, I agree. I wrote, this
example 9 years ago, to illustrate that CLOS mixins were isomorphic
with C++ mixins. I didn't apply extra design since I didn't want to
show that C++'s implementation was superior.;-)

Hopefully, C# and the CLR will eventually add generics, but in the mean
time, the decorator pattern should be more than enough for language


Take care,

Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.