Proposal : mnemonic for start index for slices

sigod via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 9 03:36:37 PDT 2015


On Saturday, 8 August 2015 at 13:42:03 UTC, John Colvin wrote:
> That would be neat, but the thing is you can already do this:
>
> auto sub = arr[idx + 123 * 10 .. $][0 .. 1];
>
> The only argument that might hold weight is that calculating 
> opDollar and doing two index/slice operations might be 
> relatively expensive for some user-defined type.

Shouldn't it be always rewritten by compiler regardless 
underlying type?

     auto sub = arr[idx + 123 * 10 .. $][0 .. 1];

->

     auto index = idx + 123 * 10;
     auto sub = arr[index .. index + 1];

I mean, does it make sense to have unequal results for this 2 
expressions?


More information about the Digitalmars-d mailing list