www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.parrallelism + scopedTask what is the right syntax

reply "bioinfornatics" <bioinfornatics fedoraproject.org> writes:

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 

what is the problem ?
Feb 21 2013
parent reply "Dicebot" <m.strashun gmail.com> writes:
On Thursday, 21 February 2013 at 08:05:08 UTC, bioinfornatics 
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.
Feb 21 2013
parent reply "Dicebot" <m.strashun gmail.com> writes:
Feb 21 2013
parent "bioinfornatics" <bioinfornatics fedoraproject.org> writes:
On Thursday, 21 February 2013 at 11:07:13 UTC, Dicebot wrote:
yes I confirm this bug. I am happy^to see that is not my fault ^^
Feb 21 2013