'final' function implementations in interface definition

HOSOKAWA Kenchi hskwk at inter7.jp
Sun Jun 7 14:58:30 PDT 2009


Hello,


Interface member functions do not have implementations. 
This specification prevents to implement macro-like small functions which won't be overridden.
It seems that interfaces are possible to have function implementations if the function is ensured not to be overridden.
Hence following list will possibly avoid problems in multiple inheritance.


interface I
{
	void f(int);
	final void f_twice(int i) { f(i); f(i); }
}

class C : I {...}

(new C).f_twice(1);



This list would be almost equivalent to another list



interface I
{
	void f(int);
}

void f_twice(I i, int n) { i.f(n); i.f(n); }

class C : I {...}

f_twice((new C), 1);



More information about the Digitalmars-d mailing list