DIP 1020--Named Parameters--Community Review Round 1

bauss jj_1337 at live.dk
Mon Apr 8 13:31:48 UTC 2019


On Monday, 8 April 2019 at 10:10:14 UTC, Yuxuan Shui wrote:
> On Sunday, 7 April 2019 at 21:19:20 UTC, Walter Bright wrote:
>> On 4/7/2019 10:14 AM, Yuxuan Shui wrote:
>>> this proposal seems to mandate the inclusion of parameter 
>>> names in mangled name of functions.
>>
>> Nope.
>
> OK, I probably misunderstood, but what happens in the following 
> case?
>
> void fun(int a, int b) {...}
> void fun(int c, int d) {...}
>
> fun(c:1, d:1);
>
>
> Is it ambiguous? Or does it invoke the second function? If the 
> latter, then you have to include the parameter names in mangled 
> name.

That wouldn't work because the compiler would reject your 
function definitions when you attempt to call either of them 
because they're ambiguous.

Just like it is today.

Basically you could look at them just being:

void fun(int,int);
void fun(int,int);

When you call a function like:

void fun(int a, int b);

...

fun(a: 1, b: 2);

the compiler would really just reorder the passed values to match 
the parameters (If they can be specified in any order, if not 
then it will just them as it is.

Which means:

fun(a: 1, b: 2);

becomes:

fun(1, 2);

and by then it should be clear why it wouldn't be allowed nor 
would work at all.


More information about the Digitalmars-d mailing list