Automatic Foreach

Janice Caron caron800 at googlemail.com
Sun Apr 27 03:58:56 PDT 2008


On 27/04/2008, janderson <askme at me.com> wrote:
> Janice Caron wrote:
>
> > Actually, I should have said that, in general, Joel's proposal is
> > undefined for all non-unary operations.
> >
> >   a[] = b[] + c[]
> >
> >   f(a[], b[], c[], d[])
> >
>  My proposal was to generate nested loops and base it of the order the
> arrays where specified. However it could just as easily be parallel for all
> values and require that all arrays are the same size.

I think I'd be happy with a template in std.algorithm.

    // a[] = b[] + c[]
    auto a = parallel!("a = b + c")(a,b,c);

    // foo(array1[], array2[], array3[], array4[])
    parallel!("foo(a,b,c,d)")(array1,array2,array3,array4);

Or some such. I'm sure Andrei could write that. He's a clever guy.



More information about the Digitalmars-d mailing list