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

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Mon Jul 13 01:47:35 PDT 2009


Bill Baxter wrote:
> On Fri, Jul 10, 2009 at 8:15 AM, Andrei
> Alexandrescu<SeeWebsiteForEmail at erdani.org> wrote:
>> Don wrote:
>>> The other thing that's desperately missing from D is multi-dimensional
>>> indexing.
>> What are the limitations of multiple-argument []?
>>
>> Andrei
>>
> 
> I don't know what Don had in mind, but multi-dimensional slice is
> ugly.  should be A[ a..b, c..d, e..f ] but currently you have to do
> something like A[ [a,c,e]..[b,d,f] ].   Or A[a..b][c..d][e..f] and
> bend over backwards to avoid creating too many temporary proxy
> objects.  Also you'd like to be able to mix and match slices and
> indices like  A[ a..b, 3, e..f ].
> 
> 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.
> 
> --bb


Either, D needs built-in multidimensional arrays, or they must be 
implemented in Phobos.

To support slicing of built-in multidim arrays, I think it is necessary 
to make slices a different type than arrays, because they would need to 
have a stride in order to slice across rows.

-Lars



More information about the Digitalmars-d mailing list