On page 217+218 there are two interfaces that define some final methods with
the same name, and a class that inherits from both:

interface Timer
{
    final void run() {}
}

interface Application
{
    final void run() {}
}

class TimedApp : Timer, Application
{
    void run() {}    // cannot define run()
}

Okay, it hijacks both methods which are final, it won't compile which is
what we want.
TDPL states: "To access those methods for app of type TimedApp, you'd have
to write app.Timer.run() and app.Application.run() for Timer's and
Application's version", where the inheriting class does not hijack the
methods.

So that would look like this:

interface Timer
{
    final void run() {};
}

interface Application
{
    final void run() {};
}

class TimedApp : Timer, Application
{
}

import std.stdio;

void main()
{
    auto app = new TimedApp;
    app.Timer.run();  // error, no Timer property
    app.Application.run(); // error, no Application property
}

This looks to me like a DMD bug? I know I can do calls like these if a class
inherits from another class:

class Timer
{
    final void run() {};
}

class Application
{
    final void run() {};
}

class TimedApp : Timer//, Application
{
}

import std.stdio;

void main()
{
    auto app = new TimedApp;
    app.Timer.run();  // works fine
    //~ app.Application.run();
}

(Note I've had to comment out inheriting Application since MI is disallowed
in D). This will now run. Is this a DMD bug?


On Sat, Aug 14, 2010 at 4:56 PM, Andrej Mitrovic <andrej.mitrov...@gmail.com
> wrote:

> I agree, NVI really looks like a nice idiom/pattern to me, I'd hate to
> loose it.
>
>

Reply via email to