Thread overview
std.parrallelism + scopedTask what is the right syntax
Feb 21, 2013
bioinfornatics
Feb 21, 2013
Dicebot
Feb 21, 2013
Dicebot
Feb 21, 2013
bioinfornatics
February 21, 2013
Hi,

I have a function like this:

void writeRegionOutLimit( in string outFile, ref const size_t[] table, bool delegate(size_t) lambda, in string delimiter = ",")

when I use it with scoped task compiling fail:

 auto job4   = scopedTask!writeRegionOutLimit( outFile ~ "min_warn.csv", table, (a => a < stat.quartile1 ), delimiter );

Error: template std.parallelism.scopedTask does not match any function template declaration
 Error: template std.parallelism.scopedTask cannot deduce template function from argument types !(writeRegionOutLimit)(string,ulong[],void,string)


what is the problem ?
February 21, 2013
On Thursday, 21 February 2013 at 08:05:08 UTC, bioinfornatics wrote:
> ...

Looks like an issue with automatic inference of lambda type for new lambda syntax. When I use old syntax "(size_t a) { return a < stat.quartile1; }", it works better. Still won't compile, though, as compiler won't convert function to delegate implicitly, std.functional.toDelegate will help. Simple working example:

----
import std.parallelism, std.functional;

void func( bool delegate(size_t) lambda )
{
    lambda(42);
}

void main()
{
    auto task = scopedTask!func( toDelegate((size_t a) { return a > 2; }) );
}
----

I'll file a bug for new lambda syntax type inference.
February 21, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9555
February 21, 2013
On Thursday, 21 February 2013 at 11:07:13 UTC, Dicebot wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=9555

yes I confirm this bug.

I am happy^to see that is not my fault ^^