Calling un-overridden class method

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Oct 12 19:46:28 PDT 2012


On Sat, Oct 13, 2012 at 04:35:12AM +0200, Andrej Mitrovic wrote:
> On 10/13/12, H. S. Teoh <hsteoh at quickfur.ath.cx> wrote:
> > The problem is, I can't seem to specify that I want it to _statically_
> > bind the save method to call B.eval;
> 
> Try using typeof(this).eval
> 
> typeof(this) and typeof(super) are mentioned here:
[...]

It doesn't help. :-(  It seems to do the same thing as B.eval, which
still ends up in C.eval.

This seems to be a compiler (or language?) bug to me? One should be able
to specify a static binding to a specific base class method, without
always ending up in the overridden method.

Anyway, I figured out a workaround: rename .save to .saveImpl and make
it private, then make .save a wrapper to call .saveImpl, and have the
delegate directly invoke .saveImpl.

It's still a pain, though. :-/


T

-- 
"The whole problem with the world is that fools and fanatics are always
so certain of themselves, but wiser people so full of doubts." --
Bertrand Russell. "How come he didn't put 'I think' at the end of it?"
-- Anonymous


More information about the Digitalmars-d-learn mailing list