Another, is it a bug?

Random D user via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 15 20:48:58 PDT 2015


On Wednesday, 16 September 2015 at 03:17:05 UTC, Meta wrote:
> Considering Father defines the function `int eat()` and 
> Daughter defines the completely different function `int 
> eat(int)`, it doesn't surprise me. You're not using virtual 
> dispatch when you do `return super.eat` or `d.Father.eat()`, 
> you're delegating the method call to the base class.

Yeah... I guess I was expecting it to overload across class 
boundaries. I mean there's already a member eat in base class and 
sub class can't override that since it's got different 
parameters, and it's a function (can't be variable), so the 
reasonable thing would be to overload it (which is why I tried 
override to see if it forces/hints overriding/overloading).
Instead it creates two ambiguous names of which only one has to 
be disambiguated to use which seems super error prone. IMO it 
should just be error/warning.

Given that, normally properties are just overloaded methods in D, 
it's pretty sad classes break this behavior/convention.


More information about the Digitalmars-d-learn mailing list