What is the sub interface?

Ary Borenszweig ary at esperanto.org.ar
Tue Mar 24 10:50:35 PDT 2009


Haruki Shigemori escribió:
> (1)
> interface A {void a();}
> interface B : A {}
> 
> (2)
> interface B {void a();}
> 
> If both interfaces of B are the *same* when paying attention to interface B,
> I think that the next code is invalid-accept about class C2.
> Because class C2 do not have a method "void a(){}".
> 
> http://www.digitalmars.com/d/2.0/interface.html
>> A reimplemented interface must implement all the interface functions,
> it does not inherit them from a super class

I think this last sentence doesn't make any sense at all. Some might
consider it an enhancement but I consider it as an issue.

> 
> interface I1 {void a();}
> interface I2 : I1 {}
> class C1 : I2 {void a(){}}
> class C2 : C1, I2 {} // invalid-accept? (dmd 2.026)
> 
> How do you think about?

You wouldn't have to break your head if implementing an interface meant
"having the methods declared in that interface". No error should appear
in C2.

What's the rationale behind this behaviour?



More information about the Digitalmars-d mailing list