hijacking override from template mixin

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 9 09:13:49 PDT 2014


On Monday, 9 June 2014 at 15:54:21 UTC, Ivan Kazmenko wrote:
> I'd expect a "multiple overrides of same function" error, much 
> like if I just paste the mixin code by hand.  Is that a bug or 
> working by design?  In the latter case, please explain the 
> reasoning.

AFAIK, the rationale is that *should* a colision happen, the 
local symbol shadows the mixed-in symbol. Doing this avoid 
breaking your code just because someone added an extra member in 
their mixin, which happened to conflict with one of yours.

The idea is that you can workaround the issue by "naming" your 
mixin templates. Then, when you want to access members of the 
mixin template, you *know* it'll always work, regardless of what 
else may have been declared in your class.

That said, for something like virrtual functions, things get a 
bit trickier, since your *aren't* supposed to call them 
explicitly... I don't know if bug, or just surprising behavior.


More information about the Digitalmars-d-learn mailing list