www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - mixin / aggregation syntax remark

Could perhaps be posted as a response to some of the other mixin
discussions, but...

I had a thought on the use of mixins and on syntactical requirements
following from that. In my mind, ideally, you would define classes and
structs as usual. Then, later on, perhaps in some other project, you would
find yourself in a situation where you realize that the class you're writing
needs this, this and that bit, all pieces of functionality that you had
already written before. So you say something along the lines of:

class X {
    reuse class Y, Z;    // or "aggregate" or "mixin", I don't really care
at the moment
}

My point is, ideally you would be able to postpone the decision to make some
functionality a 'mixin' until you find a use for it as such. This means that
there should be no special syntax to declare some class as a 'mixin', only
special syntax to use some class as a mixin

There could be restrictions, like "a class can only be used as a mixin if it
has no datamembers or virtual methods", so implicitly you would have to
foresee potential future use of a class as mixin.

Does any of this make sense?
May 01 2004