Why I'm Excited about D

ixid via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 7 01:58:56 PDT 2015


> import std.stdio, std.parallelism;
>
> auto names = [ "Adam Hawkins", "Peter Esselius" ];
>
> foreach(name; taskPool.parallel(names)) {
>     writeln(name);
> }
>
> There is a convenience function in std.parallelism that allows 
> you to write the following instead for your foreach loop:
>
> foreach (name; names.parallel) {
>     writeln(name);
> }
>
> Also, @system, @trusted, @safe don't really have much to do 
> with optimization or access levels, but safety. Theoretically, 
> if all of your code is @safe, then it is impossible for your 
> program to corrupt memory.
>
> Also, have you considered posting this article to Hacker 
> News/Reddit?

Or to be more consistent with UFCS:

foreach (name; names.parallel) {
     name.writeln;
}


More information about the Digitalmars-d mailing list