Function definition in multiple modules
Martin Drasar
drasar at ics.muni.cz
Thu Mar 29 03:58:56 PDT 2012
On 29.3.2012 12:02, simendsjo wrote:
> Your looking for partial classes? D doesn't have this as far as I know.
>
> "alias this" should work for more than one value in the future, and then
> (I think) you should be able to do something like this:
>
> class XIB : IB {}
> class XIA : IA {}
> class X : IA, IB {
> XIA xia;
> XIB xib;
> alias xia this;
> alias xib this;
> }
I was thinking about similar idea. But instead of alias this I intended
to write something like this:
class X : IA, IB {
XIA xia;
void iamethod()
{
xia.iamethod();
}
...
}
It is not very pretty though...
> But you can also solve it with mixin templates:
> mixin template XIA {
> // all IA methods
> }
> mixin template XIB {
> // all IB methods
> }
>
> class X : IA, IB {
> mixin XIA!();
> mixin XIB!();
> }
This would make the code separation easy to manage, but I am concerned
about debugging. How is e.g. gdb able to debug mixins? I think I have
read somewhere in the D or D-learn, that the dmd can produce the file
with mixed-in code for the debugger, but I am not sure how to find it.
Martin
More information about the Digitalmars-d-learn
mailing list