DIP 1019--Named Arguments Lite--Community Review Round 2
FeepingCreature
feepingcreature at gmail.com
Wed Jun 5 21:24:35 UTC 2019
On Wednesday, 5 June 2019 at 15:25:52 UTC, Exil wrote:
> I also don't see anywhere that this wouldn't be allowed?
>
> void fun( int a, int b );
> fun( a: 0, 10 );
>
Yes.
> The description shows this:
>
> void drawRect(int x, int y, int width, int height);
>
> drawRect(x: 0, y: 0, width: 1, height: 1);
> drawRect(0, 0, width: 1, height: 1); // Also valid
>
> But there is nothing in the DIP that states that this is valid
> or what rules it needs to follow? Like above with the named
> parameter appearing before arguments or inbetween.
>
Named arguments in this proposal are not positional parameters,
they're more annotations. The ordinary order of parameters needs
to be respected. (That's what makes it "Lite".) That's also why
you can't skip default parameters.
> https://run.dlang.io/is/eQ7X4p
>
> import std.stdio;
>
> class A {
> void a(int x) { writeln("A"); }
> }
> class B : A {
> override void a(int z) { writeln("B"); }
> }
>
> void main() {
> auto b = new B;
>
> b.A.a( 10 );
> b.a( 10 );
> }
This "feature" is nonsense and should be removed. It goes against
the entire point of function overriding. It's also not in the
spec.
What is in the spec is the ability to do this with fields, ie.
"int a" in B hiding "int a" in A, and I suspect this is a side
effect of that feature. (Which makes sense, for fields, as field
hiding is fundamentally different from method overriding.)
Strictly speaking the spec says "members of a base class", but I
strongly hope the use for methods is unintentional.
More information about the Digitalmars-d
mailing list