On 12/19/10, Nick Sabalausky <a...@a.a> wrote: > > int foo(int x) { ... } > map!"foo(a) * 2" // Trivial lambda, but it fails
Currently this will call unaryFunImpl, which tries to evaluate foo(a) at compile-time, but foo isn't visible from std.functional, where unaryFunImpl is defined. I don't know, maybe Phobos could construct a closure out of the string somehow if it detected that there's a function call in that string, here's some pseudocode modified from std.functional: template unaryFunImpl(alias fun, bool byRef, string parmName = "a") { static if (is(typeof(fun) : string)) { // added: detect if there's a function call in that string static if (hasFunctionCalls(fun)) { // if so construct a closure, and that should be it alias newclosure result; } else { // Otherwise do as usual in std.functional.unaryFunImpl template Body(ElementType) { } // old code... } } else { alias fun result; } }