inheritance problem

kenny funisher at gmail.com
Mon Apr 30 04:31:18 PDT 2007


> Well "limitation" may be a bit harsh. Inheritance is available but it is
> not as automatic as it is in some other languages.
> 
> The need for the alias is because D's rules for finding matching functions
> is simple (some say simplistic). If it finds a matching name in the current
> context it doesn't try to look any further (e.g in the parent class). The
> 'alias' is the syntax needed to explicitly bring the parent's function's
> name into the current context.
> 
> In your case above, because C2 contains the name 'add' your 'c.add(1,2)'
> stops looking further up the inheritance tree for a matching parameter
> signature. But by adding 'alias C1.add add', it includes all the 'add'
> functions in C1 into the namespace of C2.
> 
> This is how Walter wants D to work so if you have suggested improvements,
> you have to convince him. (Good luck <G>)
> 

Perhaps the error can instead say something more useful like suggesting to alias instead.


More information about the Digitalmars-d-bugs mailing list