On Saturday, 8 August 2015 at 13:08:08 UTC, Temtaime wrote:
Hi !
I want to add some sugar to D : sometimes it's necessary to use
complex start index.
For example:
auto sub = arr[idx + 123 * 10..idx + 123 * 10 + 1];
Proposal is to add a mnemonic for start index, for instance :
auto sub = arr[idx + 123 * 10..# + 1]; // # == start index
# is for example. Maybe it can be @ or some other symbol.
Any ideas ? Should i try to create a DIP ?
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.