Can we fix reverse operator overloading (opSub_r et. al.)?

Jarrett Billingsley jarrett.billingsley at gmail.com
Fri Jul 10 10:27:00 PDT 2009


On Fri, Jul 10, 2009 at 12:45 PM, Bill Baxter<wbaxter at gmail.com> wrote:

> Also a basic built in multi-dim array would be nice.  I think most of
> the time when people make a new T(10,20) they don't really want 10
> arrays of length 20, each of which can be individually resized (and
> must be if more capacity is needed).   They want one array with size
> 10 x 20.

Something like C#'s would be nice:

http://msdn.microsoft.com/en-us/library/aa288453(VS.71).aspx

If we were to D-ize them, they might look something like:

int[,] a = new int[,](3, 4);
a[,] = 5; // slice-assign entire array
a[2,] = 10; // slice-assign only the third row

for(int i = 0; i < a.length(0); i++) // notice .length(0)
    for(int j = 0; i < a.length(1); j++)
        writeln(a[i, j]);

auto b = a.dup;
a[0,] = b[1,]; // copy b's second row into a's first - hmm

Slicing them might be tricky, because I'm not sure what type the slice
should be.  I think maybe a[0, ] should be int[], but what the heck
would a[,0] be?  int[,4] ?

It'd require a lot more thought.



More information about the Digitalmars-d mailing list