DIP 1019--Named Arguments Lite--Community Review Round 2
Yuxuan Shui
yshuiv7 at gmail.com
Thu Jun 6 10:05:45 UTC 2019
On Wednesday, 5 June 2019 at 15:25:52 UTC, Exil wrote:
> [snip]
>> If a function is defined with some of its parameter names
>> omitted, arguments to those parameters can labeled with an
>> empty name.
>>
>> void fun(int);
>>
>> fun(:10);
>
> Why is this included, what is the use case for it? Why wouldn't
> you just use fun(10) instead? If ordering is required why
> require the ":" at all?
None of the names are required. This is provided so there is a
way to label unnamed parameters if there is a need for it.
>
>> Overridden member functions can be called with a set of names
>> matching any of the function definitions which are visible
>> through the object used to call those functions.
>>
>> class A {
>> int a(int x);
>> }
>>
>> class B : A {
>> override int a(int z);
>> }
>>
>> auto b = new B;
>> A a = cast(A)b;
>>
>> b.a(z: 1); // valid
>> b.a(x: 1); // valid
>> a.a(x: 1); // valid
>> a.a(z: 1); // error
>
> Which functions do these call? Does b.a(x: 1) call B.a() or
> A.a()? You can call A.a() specifically, this needs to be
> clarified as to which is called.
Parameter names have no effect on which function get called (as
stressed by this DIP). I will clarify that more in the next
revision.
More information about the Digitalmars-d
mailing list