On Thu, Jan 17, 2013 at 08:20:49PM +0100, Andrej Mitrovic wrote: > On 1/16/13, H. S. Teoh <hst...@quickfur.ath.cx> wrote: > > I'm guessing that most D users don't realize extent of the flexibility > > of std.format > > There's a problem: > > module test; > import std.stdio; > > class C1 { } > class C2 : C1 > { > void toString(scope void delegate(const(char)[]) put) > { > put("Subclass"); > } [...]
Hmm. The fact that this method didn't give a compiler warning/error about missing an "override" keyword indicates the root of the problem: you need to define toString in C1 and override it in C2, otherwise the toString method will not be visible via a C1 reference. (I've run into this before.) Ideally the toString variants should be put in Object, but I'm not sure if it will work well (in particular, if you overload toString with template arguments on character type, it will not be virtual so there may be some use cases that won't work). T -- "Computer Science is no more about computers than astronomy is about telescopes." -- E.W. Dijkstra