On page 217+218 there are two interfaces that define some final methods with the same name, and a class that inherits from both:<br><br>interface Timer<br>{<br> final void run() {}<br>}<br><br>interface Application<br>{<br>
final void run() {}<br>}<br><br>class TimedApp : Timer, Application<br>{<br> void run() {} // cannot define run()<br>}<br><br>Okay, it hijacks both methods which are final, it won't compile which is what we want.<br>
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.<br>
<br>So that would look like this:<br><br>interface Timer<br>{<br> final void run() {};<br>}<br><br>interface Application<br>{<br> final void run() {};<br>}<br><br>class TimedApp : Timer, Application<br>{<br>}<br><br>
import std.stdio;<br><br>void main()<br>{<br> auto app = new TimedApp;<br> app.Timer.run(); // error, no Timer property<br> app.Application.run(); // error, no Application property<br>}<br><br>This looks to me like a DMD bug? I know I can do calls like these if a class inherits from another class:<br>
<br>class Timer<br>{<br> final void run() {};<br>}<br><br>class Application<br>{<br> final void run() {};<br>}<br><br>class TimedApp : Timer//, Application<br>{<br>}<br><br>import std.stdio;<br><br>void main()<br>{<br>
auto app = new TimedApp;<br> app.Timer.run(); // works fine<br> //~ app.Application.run();<br>}<br><br>(Note I've had to comment out inheriting Application since MI is disallowed in D). This will now run. Is this a DMD bug?<br>
<br><br><div class="gmail_quote">On Sat, Aug 14, 2010 at 4:56 PM, Andrej Mitrovic <span dir="ltr"><<a href="mailto:andrej.mitrovich@gmail.com">andrej.mitrovich@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I agree, NVI really looks like a nice idiom/pattern to me, I'd hate to loose it.<div><div></div><div class="h5"><br>
</div></div></blockquote></div><br>