> Indeed. The solution to OP's problem is std.algorithm.map. Local instantiation should take care of aliases that refer to local symbols, so OP's original complaint about std.algorithm.map is invalid (albeit for a subtle reason). The following code compiles as expected: import std.algorithm, std.stdio; auto fun(int[] a) { auto y = 3; auto m = map!((x) { return x < y; })(a); return m; } void main() { auto a = [ 1, 2, 3, 4, 5 ]; auto m = fun(a); writeln(m); } > Note how map's lambda refers to a symbol local to fun.
I... didn't know that works. Wow! And it also seems to work with function pointers too. :) D amazes me every day. :D Thanks for making such a great language guys!!