Implement a class with mixins

Don Clugston dac at nospam.com.au
Mon May 8 08:32:12 PDT 2006


Sean Kelly wrote:
> Frank Benoit wrote:
>> Does a protected inheritance make sense in a language without multiple
>> inheritance? Inherit private is for a "implemented with" relation. And
>> this is perhaps better made with the mixin feature.
>>
>> But to use mixins like base classes for implementation, mixins are
>> missing a Ctor ( and DTor ) integration. It should be possible for a
>> mixin to have a Ctor which is automatically called while the object is
>> contructed. Or it can be called manually ( with args ) from the class 
>> ctor.
> 
> It would be great if there were an easy way to make this work.  As it 
> is, I have to know in advance something is intended to be a mixin and 
> create separate methods for this.  For a somewhat more complicated 
> example, I use the technique here:
> 
> http://www.home.f4.ca/sean/d/stream.d

In every case I've seen or dreamt up so far, a template is either 
intended to be a mixin, or not. Is that your experience too?
I suspect that 'mixin' should be specified in the template declaration, 
rather than just the instantiation.



More information about the Digitalmars-d mailing list