3D Math Data structures/SIMD

Janice Caron caron800 at googlemail.com
Sun Dec 23 01:29:13 PST 2007


On 12/23/07, Janice Caron <caron800 at googlemail.com> wrote:
>     Matrix!(4,4,float) a, b, c;
>     foreach(ref x;a)(y:b)(z:c) x = b * c;

Typo. Should read

    Matrix!(4,4,float) a, b, c;
    foreach(ref x;a)(y:b)(z:c) x = y * z;

To add to that, Walter has always argued that foreach expresses what
the programmer /wants/, not how it's implemented, and that it's up to
the compiler to figure out the most efficient way to implement it,
which might be different on each platform, and might indeed include
parallelisation, if the compiler thinks it's worth it. I tend to agree
with this, and I see no problem with extending foreach for builtin
arrays. The big problem with it is user-defined types, because opApply
just isn't the right way to implement foreach in these cases. Perhaps
the long term solution is iterators - then foreach for user-defined
types could be implemented by the compiler using iterators instead of
opApply?



More information about the Digitalmars-d mailing list