Pretty please: Named arguments
Bekenn
leaveme at alone.com
Mon Feb 28 11:05:41 PST 2011
On 2/28/11 4:41 AM, Michel Fortin wrote:
> Another problem is what happens if you override a function by using
> different parameter names. For instance:
>
> class A {
> void func(int foo);
> }
> class B : A {
> void func(int bar);
> }
>
> Currently, the above is allowed. Would it now become an error?
Definitely not an error! This feature should not break any existing code.
Method lookup already happens based on the static type of your object
reference; that shouldn't change:
A a = new A;
a.func(foo = 3); // ok
a.func(bar = 3); // Error, argument name does not match parameter name
B b = new B;
b.func(foo = 3); // Error, argument name does not match parameter name
b.func(bar = 3); // ok
A c = new B;
c.func(foo = 3); // ok
c.func(bar = 3); // Error
More information about the Digitalmars-d
mailing list