On 6/14/17 5:34 AM, Balagopal Komarath wrote:
Why doesn't this work? The Test!Duck type has a void quack() method but
the compiler says it is not implemented.
import std.stdio;
interface IDuck
{
void quack();
}
class Test(T) : IDuck
{
T data;
alias data this;
}
struct Duck
{
void quack()
{
writeln("Quack");
}
}
void main()
{
Test!Duck d;
}
An alias never causes implementation to be emitted. It should just be a
forward from one symbol name to another. You need an actual function
that can go into the vtable that takes a 'Test!Duck' as the context
pointer. This wrapper has to be written by you.
-Steve