reddit discussion about Go turns to D again

Andrej Mitrovic andrej.mitrovich at gmail.com
Sun May 15 16:13:49 PDT 2011


It'd be nice if std.parallelism could somehow wrap std.algorithm
functions with a template instead of creating special names like
parallelCount, parallelMap, etc.. I'm thinking of something like:
static import std.algorithm.count;
alias Parallel!(std.algorithm.count, 10) count;  // 10 threads
auto negatives = count!"a < 0"(data);

Parallel would be a template which would know about std.algorithm
functions, and would statically disallow instantiating a template with
some algorithm which doesn't have a parallel implementation yet. Of
course someone would have to write these algorithms.

Then when you have a problem and want to eliminate that the cause is a
race condition you might do:

version(MultiCore)
{
     alias Parallel!(std.algorithm.count, 10) count;
}
else
{
    alias std.algorithm.count count;
}

I dunno, maybe that's just overkill and fantasizing (and probably
wouldn't work..).

Either way having parallel algorithms at the reach of a single import
sounds great, it could be one of D's top library features.


More information about the Digitalmars-d mailing list