22-Mar-2013 23:03, deadalnix пишет:
On Friday, 22 March 2013 at 18:48:56 UTC, timotheecour wrote:
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

Don't have time to look at the code now, but it seems awesome ! Great
leverage of language capabilities. Slightly different from my proposal,
but I'm really not sure which interface fit best. I'm starting to think
this should be :

callNamed!(fun,`x`, `y`)(10,20);

Can opDispatch & chaining  be leveraged to get the effect of:
named!(fun).x(10).y(20).call();

Or maybe even simpler?

But I'm not sure of all the pro and cons.


--
Dmitry Olshansky

Reply via email to