Non-Virtual Interfaces
Aleksandar Ružičić
ruzicic.aleksandar at gmail.com
Fri Mar 4 02:17:00 PST 2011
I'm trying to use NVI idiom but i keep getting errors from dmd.
This is my setup:
module test;
import std.stdio;
interface IBase {
void foo();
void bar();
}
interface IBar : IBase {
final void bar() {
writefln("IBar.bar()");
}
}
class Foo : IBar {
void foo() {
writefln("Foo.foo()");
}
}
void main() {
Foo foo = new Foo();
foo.foo();
}
When I try to compile it i get "test.d(16): Error: class test.Foo
interface function IBar.bar isn't implemented"
And if I try to define bar() in Foo i receive "test.d(22): Error:
function test.Foo.bar cannot override final function
IBar.test.IBar.bar"
which is expected since IBar.bar() is final.
So, am I missing some point about NVIs here or is it just not yet
implemented in dmd?
More information about the Digitalmars-d-learn
mailing list