Arrays of an interface

Abdulhaq alynch4047 at gmail.com
Tue Dec 31 06:22:16 PST 2013


Hi all, hoping someone can help,

I'm used to coding to interfaces and I'm using them very lightly 
in an application I'm writing (a CPP wrapper like SWIG, except in 
D). Every now and then I touch a piece of code which seems almost 
unrelated and then get a bunch of compile errors such as the 
following (Method is the interface, MethodImpl is the 
implementation):

smidgen/ast/klass.d(108): Error: function 
smidgen.ast.klass.Klass.addMethod (Method method) is not callable 
using argument types (MethodImpl)
smidgen/ast/klass.d(113): Error: function 
smidgen.ast.klass.Klass.addMethod (Method method) is not callable 
using argument types (MethodImpl)
smidgen/ast/klass.d(293): Error: cannot append type 
smidgen.ast.method.Method to type Method[]
smidgen/ast/klass.d(322): Error: forward reference to 
getAllWrappedMethods
smidgen/ast/klass.d(360): Error: forward reference to type 
Method[]
smidgen/ast/klass.d(360): Error: cannot implicitly convert 
expression (baseMethods) of type Method[] to Method[]
smidgen/ast/klass.d(363): Error: cannot implicitly convert 
expression (baseKlass.methods) of type Method[] to Method[]
smidgen/ast/klass.d(542): Error: forward reference to 
getAllWrappedMethods
smidgen/ast/klass.d(636): Error: forward reference to 
getAllWrappedMethods
smidgen/ast/klass.d(672): Error: forward reference to 
getAllWrappedMethods
smidgen/ast/klass.d(15): Error: size of type Method is not known
smidgen/ast/klass.d(709): Error: function 
smidgen.ast.klass.Klass.isCovariantMethod (Method otherMethod) is 
not callable using argument types (Method)
smidgen/ast/klass.d(746): Error: forward reference to type 
Method[]
smidgen/ast/klass.d(746): Error: cannot implicitly convert 
expression (allWrappedMethods) of type Method[] to Method[]

I have a feeling that D doesn't fully support arrays of 
interfaces, e.g. Method[], particularly as a return type. Is 
there a better way to pass around lists of instances of an 
interface? I'm using DMD 2.064 on Linux 64bit,

thanks


More information about the Digitalmars-d-learn mailing list