Code example in std.parallelism fails to compile

Nordlöw via Digitalmars-d digitalmars-d at puremagic.com
Tue Nov 29 04:09:32 PST 2016


The code example at https://dlang.org/phobos/std_parallelism.html

containing:


import std.algorithm, std.parallelism, std.range;

void main() {
     immutable n = 1_000_000_000;
     immutable delta = 1.0 / n;

     real getTerm(int i)
     {
         immutable x = ( i - 0.5 ) * delta;
         return delta / ( 1.0 + x * x ) ;
     }

     immutable pi = 4.0 * taskPool.reduce!"a + b"(
         std.algorithm.map!getTerm(iota(n))
     );
}

fails to compile as

std/parallelism.d(2632,36): Error: function 
std.parallelism.TaskPool.reduce!"a + 
b".reduce!(MapResult!(getTerm, Result)).reduce cannot get frame 
pointer to D main

on Git master.

Why?

Is there a solution?


More information about the Digitalmars-d mailing list