DIP 1019--Named Arguments Lite--Final Review

Paul Backus snarwin at gmail.com
Fri Aug 23 19:48:59 UTC 2019


On Friday, 23 August 2019 at 19:33:07 UTC, Dennis wrote:
> Correction:
> ```
> import std.stdio;
> void foo(int a, int b) {writeln("0");}
> void foo(int b, double a) {writeln("1");}
> void main()
> {
>     foo(b: 10, 0);
> }
> ```
>
> The point is, is an exact type match more important than 
> parameter order match?

Walter's proposal from the previous discussion was that named 
parameters should use the same rules for reordering as named 
struct initialization [1] (which in turn are the same rules used 
by designated initializers in C99 [2]). So in this case, the 
second overload would be called, because it's the only one with a 
parameter after `b`.

Even if these aren't your favorite rules, I think there's a lot 
to be said for consistency.

[1] https://dlang.org/spec/struct.html#static_struct_init
[2] http://port70.net/~nsz/c/c99/n1256.html#6.7.8p17


More information about the Digitalmars-d mailing list