Build interface from abstract class

DigitalDesigns DigitalDesigns at
Tue May 29 19:06:24 UTC 2018

On Monday, 28 May 2018 at 22:15:40 UTC, arturg wrote:
> this might help you,
> you can use them to generate the functions as strings.


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 

interface 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 

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
		int xe = 3;
		@(3) void foo() { }

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

		B bar() { return null; }

abstract class D : C, B


fails because 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.

More information about the Digitalmars-d-learn mailing list