On Sun, Jan 30, 2011 at 12:03, Tom <t...@gmail.com> wrote: > I would like to thank you for that such a great explanation of the > Template-based > programming in that unary example. I think it's great you have uploaded that > to > the wiki4d, and it's definite will help a lot of people that come from other > common languages background (like C, C# and Python) that don't support full > templating, to understand that design pattern. > And with that close tracking to the functional.d code, I thing but not sure > that > we've found some bugs. I will do some testing later today, and if I will see > what > I think to be wrong, I'll update.
If anyone is interested, I coded a n-args version of unaryFun/binaryFun called naryFun. If you use 'a', 'b', ... as args names, it can automatically determine the templated function arity. So naryFun!"a + b * c - sin(d-a)" is a 4-args template function. It's there: http://svn.dsource.org/projects/dranges/trunk/dranges/docs/functional.html (look for naryFun at the bottom) code is here: http://dsource.org/projects/dranges/browser/trunk/dranges/functional.d It could be simpler now: when I did it 18 months ago, CTFE wasn't so powerful. The looping templates can now easily be done with a simple foreach. This has been on my todo list for quite some time... Philippe