Satisfying interface requirements

Chris Nicholson-Sauls ibisbasenji at
Thu Jul 26 13:29:50 PDT 2007

Jason House wrote:
> Attached is a simple example that demonstrates my problem (with dmd 1.018).  It seems like inheriting from a class that contains functions that would satisfy an interface does not work.  Usually, I work around this by just adding a manual call to super's copy.  Unfortunately, this only works if super's member function is not final.  Any tips on how to work around this?
> If line 7 is commented out:
> test.d(6): class interface function bar.start is not implemented
> If line 7 is present:
> test.d(7): function cannot override final function tango.core.Thread.Thread.start

The standard technique is to use an alias, like so:

interface Foo {
   int bar();

class A {
   int bar();

class B : A, Foo {
   alias bar;

Although, personally, I'm not entirely satisfied with this.  I would 
think checking for interface implementation warrants a look up the 
inheritance chain.  I think there was a reason given in an older 
discussion, but darned if I can remember it now.

-- Chris Nicholson-Sauls

More information about the Digitalmars-d-learn mailing list