On Monday, 28 May 2018 at 22:15:40 UTC, arturg wrote:
this might help you,
https://dpaste.dzfl.pl/2cf844a11e3f

you can use them to generate the functions as strings.

Thanks,

So, the problem I'm having is that I cannot use the generated interface for the abstract class because the abstract class needs the interface defined. I need to be able to forward define the interface then extend it.

D doesn't like this

main.d(10): Error: interface `main.B` base `A` is forward referenced

interface A;
mixin(Generate!(B,A));
interface B : A
{

}

abstract class C : B
{

}

I could see that D wants A so it can have the complete picture for B, but this is one of those problems where it shouldn't matter.


This requires hoops and ultimately does not solve the problem. Any time A is used it will be treated as undefined by the compiler and throw an error.

For example:




pragma(msg, InterfaceFromClass!(C, "A"));

mixin(InterfaceFromClass!(C, "A"));

interface B : A
{

}

abstract class C
{
        @("InterfaceMembers")
        {
                int xe = 3;
                @(3) void foo() { }

                @property int x() { return 3; };

                B bar() { return null; }
        }
        
}

abstract class D : C, B
{

}

fails because C.bar returns a B, which has not yet fully been defined because A has not yet fully been defined. Now, if I could just get the function signature without using the type system, this wouldn't be a problem. I don't really care if B is defined yet, I just need to know it's name. I guess D tries to enforce consistency at all steps, which is a problem here because C uses a yet to be defined type, even though it will be defined soon enough without problems.

One of the main culprits is isCallable which is what errors out because of the yet to be defined B.

So, I guess some other method will have to work.


Reply via email to