Just for the record, the Classes chapter were a *lot* of fun. Andrei kept the chapters relatively simple, so they're easy to grasp (imo). I thought I was going to spend weeks trying to understand classes in D, but the class features really tie in nicely together. I have yet to reach the operator overloading chapter ( it's pushed way back to chapter 12, I'm not sure why). I remember I had a really tough time understanding overloading in C++ many years ago, I'll see how this one goes..
On Sat, Aug 14, 2010 at 7:45 PM, Andrej Mitrovic <andrej.mitrov...@gmail.com > wrote: > 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. >> >> >