Multidimensional slice

Nekroze nekroze at eturnilnetwork.com
Wed Dec 19 05:28:23 PST 2012


On Wednesday, 19 December 2012 at 12:27:32 UTC, Rafael wrote:
> 1) It is possible to implement multiindex access using opIndex* 
> methods, moreover this is the simplest way to multiindex access 
> realization. So, we have [i, j, k] notation. Next step after it 
> - slices implementation and it looks logical to save the same 
> notation for it: [i1..i2, j1..j2, k]. But it impossible, if I 
> understand correctly.
>
> 2) On the other hand. Syntax via [i][j] leads to some overhead: 
> first index access [i] must return some light accessor object 
> (like range (or iterator)) which supports the index access 
> operation. But using this approach it is possible to implement 
> multidimensional slices. And this means, that opIndex* methods 
> with multiindex are not needed.

Well if you are looking at operator overloading you can overload 
opSlice as described here 
http://dlang.org/operatoroverloading.html#Slice however i am not 
sure if you can defined multiple slices delimited by commas in 
the same [] block but it is worth a try.


More information about the Digitalmars-d-learn mailing list