While we're at it - I would also like to see the two forms of "variadic" named arguments:

1) Implicit Associative Array Version: works similar to Ruby

void foo(string[string] args...){
    foreach(k,v;args){
        writeln("%s = %s",k,v);
    }
}

foo("a":"b","c":"d");

prints:
a = b
c = d



2) Templated Version: not sure about the declaration syntax. Maybe:

void foo(T[...])(T args){
    foreach(field;__traits(allMembers,T)){
writeln("%s(%s) = %s",field,typeof(__traits(getMember,args,field)).stringof,__traits(getMember,args,field));
    }
}

foo(a:1,b:"2");

prints:
a(int) = 1
b(string) = 2

Reply via email to