Since (SIMD) vectors are so common and every reasonabe system support them in one way or the other (and scalar emulation of this is rather simple), why not have support for this in D directly?

Yes, the array operations are nice (and one of the main reasons for why I like D :) ), but have the problem that an array of floats must be aligned on float boundaries and not vector boundaries. In my mind vectors are a primitive data type that should be exposed by the programming language.

Something OpenCL-like:

        float4 vec;
        vec.xyzw = {1.0,1.0, 1.0, 1.0}; // assignment
        vec.xyzw = vec.wyxz; // permutation
        vec[i] = 1.0; // indexing

And then we can easily immagine some extra nice features to have with respect to operators:

        vec ^ vec2; // 3d cross product for float vectors, for int vectors xor

Has this been discussed before?

/ Mattias

Reply via email to