Thanx for all your help, i just solved the problem with mixins like this: string res = ""; for(i, rev v; args) res ~= string.format(", f(args[%d]).val()"); mixin("return G(" ~ res ~ ");"); Only without any actual looping and variables, so compiler could deal with it.