DIP 1030--Named Arguments--Community Review Round 1 Feedback

Arine arine123445128843 at gmail.com
Sun Feb 9 05:09:37 UTC 2020


In the D spec it's stated arguments are evaluated from left to 
right. I know DMD doesn't follow the spec (but LDC2 does). It 
needs to be outlined how arguments are evaluated. What makes 
sense at the call site, or based on the function order. As 
arguments can be passed out of order now.

     __gshared int i = 0;
     void foo(int a = ++i, int b = ++i, int c = ++i, int d = ++i, 
int e = ++i) {
     	writeln(a, " ", b, " ", c, " ", d, " ", e);
     }


     foo(d: ++i, b: ++i); // what does this print?

How does this work with forward declaring? If the same overload 
of function is forward declared multiple times? If it is forward 
declared in the same place as a function? What about for 
interface files .di?

     void foo(int b) { }
     void foo(int a);

     void bar(int d); // declared elsewhere

     foo(a: 10); // ok or no?

     bar(d: 10); // ok?

Otherwise this seems ok.




More information about the Digitalmars-d mailing list