What is the sub interface?

Christopher Wright dhasenan at gmail.com
Tue Mar 24 14:43:50 PDT 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:

Time #1:
module library.something;
interface TheInterface
{
}

module mycode.mymodule;
class TheBaseClass
{
	void frob () {}
}
class TheClass : TheBaseClass, TheInterface
{
}



Time #2:
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
}



More information about the Digitalmars-d mailing list