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

Walter Bright newshound2 at digitalmars.com
Fri Feb 7 20:02:18 UTC 2020


On 2/6/2020 7:49 PM, Timon Gehr wrote:
> 
> import std.typecons;
> alias t=AliasSeq!(c:1, a:2, b:3); // valid according to DIP
> void foo(int a,int b,int c){
>      writeln(a," ",b," ",c);
> }
> 
> void main(){
>      foo(t);
> }
> 
> I'd expect this to print "2 3 1".
> 
> I think this is important for forwarding applications, so deserves explicit 
> treatment. There should also be a way to access the argument names in a given 
> sequence.
> 
> This is also the reason why I think this part of the DIP is probably not ideal: 
> "If there are more NamedArguments than Parameters, the remainder match the 
> trailing ... of variadic parameter lists, and Identifiers are not allowed."
> 
> IMHO, any leftover named arguments should be collected into the variadic 
> parameters.

So,

     void foo(int a, ...);

called with:

     foo(b:1, 2)

should be the equivalent of:

     foo(2, 1)

?


More information about the Digitalmars-d mailing list