this is almost a workaround for the lack of named parameters
timotheecour
timothee.cour2 at gmail.com
Fri Mar 22 11:48:55 PDT 2013
so i hacked up a working solution yesterday.
advantages over
https://github.com/jacob-carlborg/mambo/blob/master/mambo/util/Reflection.d#L135:
no need to no arguments at CT (just names); allows optional and
non optional ones; allows return value; also, mambo depends on
tango and is hard to revive.
More later.
see:
https://github.com/timotheecour/dtools/blob/master/dtools/util/functional.d
nothing to install, just call:
rdmd --main -unittest dtools/util/functional.d
auto s=callNamed!(fun,`x,y`)(10,20);
given a function:
auto fun(int x,int y=2,double z=z_val, string z2="asdf");
Compile time errors will occur on duplicate param names, or ones
that don't exist, or ones that are not optional and not provided
(eg x, above)
Feel free to contribute / comment
More information about the Digitalmars-d
mailing list