On Wed, 22 Sep 2010 16:03:08 -0400, Steven Schveighoffer <schvei...@yahoo.com> wrote:

I'll give you an example (with a new keyword to help you understand the difference):

weaklypure void reverse(int[] x)
{
    for(int i = 0; i * 2 < x.length; i++)
        swap(x[i], x[$-1-i]);
}

A better example -- std.algorithm.sort can be made weakly pure (at least for arrays). It doesn't affect anything but the array passed in.

Without this, you can't sort arrays within pure functions unless you make a strong-pure functional sort, which will likely not perform as well.

I'm kind of excited to think that D might be able to parallelize things in the right places, and allow imperative algorithms to stay imperative within those parallelized functions.

-Steve

Reply via email to