The point is I _want_ a delegate.
Atila
On Thursday, 18 September 2014 at 20:51:30 UTC, Jared wrote:
On Thursday, 18 September 2014 at 19:49:00 UTC, Atila Neves
wrote:
Or what I really want to ask: why can't I call amap from
std.parallelism with a lambda? I assume it's because it's a
member function but I'm not 100% sure.
Atila
You have to tell DMD that the lambda is not in fact a delegate.
import std.stdio;
import std.range;
import std.parallelism;
void main()
{
auto w = iota(0,1_000_000);
int[] foo;
// Not OK, dmd can't infer lambda isn't a delegate
// foo = taskPool().amap!(a => a + 1)(w);
// OK:
foo = taskPool().amap!`a+1`(w); // string lambdas, yeah!
foo = taskPool().amap!(function int(int a) => a + 1)(w);
static int func(int a) { return a + 1; }
foo = taskPool().amap!func(w);
}