Proposal : mnemonic for start index for slices
Rikki Cattermole via Digitalmars-d
digitalmars-d at puremagic.com
Sat Aug 8 06:12:22 PDT 2015
On 9/08/2015 1:08 a.m., 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 ?
Ohhhhh the start value not the start index.
Humm, I'm ok with this. It would pair and match with $ which means end
in regex with ^ meaning start.
Although I'm sure Walter will say no.
import std.stdio;
void main() {
int[] values = [1, 2, 3];
writeln(values[0 .. ^ + 3]);
}
More information about the Digitalmars-d
mailing list