http://d.puremagic.com/issues/show_bug.cgi?id=6345

           Summary: A different kind of vector operation
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2011-07-18 12:15:46 PDT ---
Currently (DMD 2.054) this is not allowed, but a vector op like this is
sometimes useful to me:

struct Foo {
    int x, y;
    int[100] array;
}
void main() {
    auto foos = new Foo[100];
    foos[].y += 10; // ********
}


For the programmer I think the meaning of such code is easy enough to
understand and use.

At the moment I don't see the need to define a operator overload for this too
(I mean something like opSliceUnary).


Don notes:

> An interesting use case:
> void main()
> {
>     cdouble[100] foos;
>     foos[].re = 5.0;
> }



Wilfried Kirschenmann suggests:

> void main() {
>   auto foos = new Foo[100];
>   auto ints = new int[100]
>   ints = foos[].y;
> }
> 
> This would simplify the wrinting of numerous application, especially
> in the writing of image/video processing (eg. rgb2yuv conversions)
> This would also simplify the writing of template library transforming
> "array of struct" to "struct of arrays" in a transparent manner for
> the library user.


Andrej Mitrovic notes (I don't understand this):

> float[] buffers = malloc..;
> float*[] CBuffers = buffers[].ptr;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to