On Thursday, 17 October 2013 at 18:00:20 UTC, Vitali wrote:
I expected slices to be in D (http://dlang.org/arrays.html) like they are in Go (http://blog.golang.org/go-slices-usage-and-internals). But they are not.

Why the array have to be reallocated after the length of a slice is changed? It makes slices useless.

Here a little example (it fails):

  void testSlices() {
    int[] dArr = [10, 11, 12];
    int[] dSlice = dArr[0..2];
    dSlice.length++;
    assert(dArr[2]==dSlice[2]); // failure
  }

What's the use case for this? I haven't found myself ever needing something like that so far, but i'd be open to seeing an example.

Reply via email to