Code example in std.parallelism fails to compile

Stefan Koch via Digitalmars-d digitalmars-d at puremagic.com
Tue Nov 29 04:49:53 PST 2016


On Tuesday, 29 November 2016 at 12:09:32 UTC, Nordlöw wrote:
> 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?

Define the function you want to call globally.
and not inside another function.


More information about the Digitalmars-d mailing list