Inheritance of mixin
tsbockman via Digitalmars-d
digitalmars-d at puremagic.com
Mon May 2 09:41:01 PDT 2016
On Saturday, 30 April 2016 at 01:06:18 UTC, Andrew Benton wrote:
> Additionally, any libraries that provide a base class with a
> mixin require inheritors to know about that mixin and provide
> it in their own code. It certainly isn't going to happen in
> every case, but if the needed functionality is provided by
> mixins, then users of the library could have problems.
I spent a while trying to figure out how to automatically verify
that a mixin required by a class hierarchy is included in all
derived classes, and failed to come up with a general purpose
solution. (I found a partial solution involving a `this T`
templatized constructor, but it had a lot of problems.) So, I
agree now that this is a problem worth solving.
It could be fixed by extending template mixins as you and others
have proposed.
Another possible solution would be to fix `this T` template
functions to be virtual, and automatically generate an override
for each derived class. This would directly solve the most common
use case, and also provide an (awkward) way to automatically
verify mixin inclusion in derived classes for more complex
scenarios.
More information about the Digitalmars-d
mailing list