I don't like slices in D
Vitali
notavailable at mail.com
Thu Oct 17 11:00:18 PDT 2013
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
}
More information about the Digitalmars-d
mailing list