On 5/25/2011 5:43 PM, bearophile wrote:
alias A.foo foo;  // ### Why the extra steps is needed for the compiler
to 'know' overloaded functions from base classes?

Others have already answered. I also suggest you to compile your code using the 
-w switch when possible.

Bye,
bearophile

>That is to prevent silently changing the program's behavior. b.foo(1) >could happily be a call to B.foo(long) today. Imagine one of the base >classes changed and now there is A.foo(int). Then our b.foo(1) would >silently start calling that new function. That would cause a tough bug.
>Ali

Ok.. Just to protect a auto promotion error from a base class.

Would not it be a better keyword such as:

class A{
    // assuming there is a new keyword of noinherit
noinherit void foo(int x){} // all other method can be inherited in A except for this class
}

If such an AliasDeclaration is not used, the derived class's functions completely override all the functions of the same name in the base class, even if the types of the parameters in the base class functions are different. If, through implicit conversions to the base class, those other functions do get called, an std.HiddenFuncError exception is raised: ?

What is the default encapsulations of a class functions? (public/private/package...) I assume that the example shown here are public because they are used in function bar?

How about when the inheritance tree becomes deeper than 4? And more and more overloaded functions are in different classes?

Does it mean we have to do more alias at child class at the bottom?<<MORE hard to solve issues.

If I am not mistaken, in C++/Java. They will choose the most bottom up closes parameter type signature match.

--
Matthew Ong
email: on...@yahoo.com

Reply via email to