digitalmars.D - What is the sub interface?
- Haruki Shigemori (15/16) Mar 24 2009 (1)
- Ary Borenszweig (7/28) Mar 24 2009 I think this last sentence doesn't make any sense at all. Some might
- Christopher Wright (32/37) Mar 24 2009 Naming collisions and different library versions. In practice, I suspect...
(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.htmlA reimplemented interface must implement all the interface functions,it does not inherit them from a super class 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?
Mar 24 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.htmlI think this last sentence doesn't make any sense at all. Some might consider it an enhancement but I consider it as an issue.A reimplemented interface must implement all the interface functions,it does not inherit them from a super classinterface 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?
Mar 24 2009
Ary Borenszweig wrote: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?Naming collisions and different library versions. In practice, I suspect this comes up very rarely. An example: module library.something; interface TheInterface { } module mycode.mymodule; class TheBaseClass { void frob () {} } class TheClass : TheBaseClass, TheInterface { } module library.something; interface TheInterface { // hey, that's new void frob (); } module mycode.mymodule; class TheBaseClass { void frob () {} } class TheClass : TheBaseClass, TheInterface { // wait, that frob doesn't do the right thing }
Mar 24 2009