Sadly the answer is no. This is due to https://issues.dlang.org/show_bug.cgi?id=5710 which apparently no-one is either willing or able to fix. The problem afflicts dmd, l;dc2 and I suspect gdc.
cf. https://github.com/russel/Pi_Quadrature/tree/master/D for some extra detail and some workarounds. It appears I had not added this original version, but I am now fixing this. On Fri, 2016-02-19 at 21:57 +0000, Ish via Digitalmars-d-learn wrote: > This code snippet is from: > http://dlang.org/phobos/std_parallelism.html > --- > import std.algorithm, std.parallelism, std.range; > > void main() { > // Parallel reduce can be combined with > // std.algorithm.map to interesting effect. > // The following example (thanks to Russel Winder) > // calculates pi by quadrature using > // std.algorithm.map and TaskPool.reduce. > // getTerm is evaluated in parallel as needed by > // TaskPool.reduce. > // > // Timings on an Athlon 64 X2 dual core machine: > // > // TaskPool.reduce: 12.170 s > // std.algorithm.reduce: 24.065 s > > 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)) > ); > } > > dmd compiler gives error: > /usr/include/dmd/phobos/std/parallelism.d(2624): Error: function > std.parallelism.TaskPool.reduce!"a + > b".reduce!(MapResult!(getTerm, Result)).reduce cannot get frame > pointer to D main > > Is there way to compile it? > > -Ish -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: rus...@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
signature.asc
Description: This is a digitally signed message part