Eigenpoll : D wish list : named tuple
the named tuple is needed for struct and class tupleof.
the named tuple is typetuple[const char[]].
A.names should be return const char[][].
A.values should be return typetuple.
Example:
struct A{
int x,y;
}
void main(){
foreach(char[] name, T;A.tupleof){
writef(name ~ ":%s", T);
}
writefln();
}
Example 2:
struct A{
int test(){}
int test2(){}
}
int delegate()[char[]] toAssociativeArray(TL...)(){
int delegate()[char[]] rv;
foreach(char[] name,T;TL){
rv[name] = &T;
}
return rv;
}
void main(){
int delegate()[char[]] list = toAssociativeArray!(A.tupleof)();
list["test"]();
list["test2"]();
}
Report this item for cleanup