Extending an interface or class outside of it
Jonathan M Davis
jmdavisProg at gmx.com
Mon Nov 25 22:15:00 PST 2013
On Tuesday, November 26, 2013 01:27:49 Frustrated wrote:
> I have some type of automatically generated interface using a
> mixin an would like to extend them after they are generated:
>
> mixin(GenerateMyInterface!(...));
>
> ... <Here I would like to add some members/methods to
> MyInterface which was generated above> ...
>
> Is this at all possible?
No. All members of a class or interface must be declared inside that class or
interface. It's possible to define them elsewhere (albeit a bit of a pain), but
it's not possible to declare them elsewhere. A class, struct, or interface
declaration cannot be broken up. So, if you're generating a class or interface
and mixing it in, you have to mix the entire thing in at once. You could build
what you're mixing in from multiple mixins (especially if you're using string
mixins), but once you create the interface declaration, it is what it is.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list