On Thursday, 17 October 2013 at 18:33:01 UTC, Ali Çehreli wrote:
On 10/17/2013 11:00 AM, Vitali wrote:
>
> Here a little example (it fails):
>
>    void testSlices() {
>      int[] dArr = [10, 11, 12];
>      int[] dSlice = dArr[0..2];
>      dSlice.length++;

That operation has a potential of relocating the slice.

I'd be curious to see if this would ever relocate:

int[] dArr = [10,11,12];
const(int)[] dSlice = dArr[0..2];
dSlice.length++;

It shouldn't, since growing a const slice can never clobber the underlying array, but I don't know if the current implementation handles this case. Still, growing a const slice seems like a pretty useless thing to do, since you can only expect to end up with default values at the end.

Reply via email to