Obtaining argument names in (variadic) functions

data pulverizer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 16 13:24:38 PDT 2016


Hi D gurus,

is there a way to obtain parameter names within the function 
body? I am particularly interested in variadic functions. 
Something like:

void myfun(T...)(T x){
     foreach(i, arg; x)
         writeln(i, " : ", arg);
}

void main(){
     myfun(a = 2, b = "two", c = 2.0);
}

// should print
a : 2
b : two
c : 2.0

Thanks in advance

Loving the mixins and tuples


More information about the Digitalmars-d-learn mailing list