Compile-time optimization
JS
js.mdnq at gmail.com
Wed Jul 24 11:42:48 PDT 2013
On Wednesday, 24 July 2013 at 18:12:37 UTC, JS wrote:
T,
Also, I've tried to wrap the template in a function and I can't
get it to work:
string join(T...)(string delim, T args)
{
return tupleStringReduce!(args);
}
it seems tupleStringReduce just returns the tuple of of the
optimized strings. I'll still need to write code that will deal
mixing in the actual compile time and runtime code.
This doesn't seem that hard as tupleReduce essentially outlines
the approach. The difference is instead of calling func directly
I sort of need to mix it in as a code string.
e.g., for tupleStringReduce, func is x~y. I need to build a
string using that "((arg[0]~arg[1])~arg[2])..." which is then
mixed in at compile time but at runtime evaluates to a string(not
an array).
Since there is no .codeof, AFAIK, I guess the only way to do this
is pass func, and the func code string("x~y") in this case.
The idea though is to use the lamba as a ctfe to reduce the tuple
when possible but *also* use it at runtime to evaluate the tuple.
Any ideas?
More information about the Digitalmars-d
mailing list