opIndex() may hide opSlice()

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Sun Mar 12 03:19:28 PDT 2017


On Friday, 10 March 2017 at 18:43:43 UTC, H. S. Teoh wrote:
>
> 	IndexRange opSlice(int x, int y) { ... }

Why is opSlice a method-operator?

Wouldn't it be better if you could do something more general

auto idx_selection = (1,3,5); // select element 1, 3 and 5
auto idx_range = (0..4); // select element 0,1,2,3
auto idx_mixed = (0..3,4,5) // select 0,1,2,4,5
auto idx2d_range = [(0..4,5), (0..6)]  // select intersections of 
rows and columns

etc...


More information about the Digitalmars-d mailing list