I've tried to implement a const, non-const accessor for a class similar to c++:
   a& at(int) const;
   a at(i);

With class it works as expected
class C1 
{
        int a;
        const int foo() { return 2; }
        ref int foo()   { return a; }
} 


Than I wanted to do it using interfaces:
interface I1 {
        const int foo();
        ref int foo();
}
                          
class C2 : I1
{
        int a;
        const int foo() { return a; }
        ref int foo()   { return 2; }
}   

but it won't compile (the interface itself compiles but i could not write any 
class implementing the interface I1)

When inheriting interfaces do code won't even compile:
interface IConst {
        const int foo();
}

interface IMutable : IConst {
        ref int foo();
} 


The compiler error i get (using dmd 2.032 on windows):
t2.d(71): Error: function t.IMutable.foo of type ref int() overrides but is not
covariant with t.IConst.foo of type const int()
t2.d(90): Error: function t.C2.foo of type ref int() overrides but is not 
covariant with t.I1.foo of type const int()

Is it a normal behavior, a bug or i've missed something ?

Thanks

Reply via email to