Implicit Interface Deduction

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Dec 13 15:27:40 PST 2015


On 12/13/2015 02:09 PM, Faux Amis wrote:
> interface IA {}
> interface IB {}
> interface IC {}
> interface IAB : IA, IB {}
> interface IBC : IB, IC {}
>
> class C : IA, IB, IC {}
> // Defining C as : IAB, IBC
> // is not really scalable ;)
>

It is not automatic at least because of implementation details: The 
compiler should not generate a vtbl for every possible interface.

Is it acceptable to add IAB and IBC to C? If so, this works:

import std.stdio;

class C : IA, IB, IC, IAB, IBC {
     void a() { writeln(__FUNCTION__); }
     void b() { writeln(__FUNCTION__); }
     void c() { writeln(__FUNCTION__); }
}

Ali



More information about the Digitalmars-d-learn mailing list