Dynamic arrays in D 1.0
boyd
gaboonviper at gmx.net
Mon May 12 01:34:03 PDT 2008
I think it's because erase and insert are really just the inverse of
slicing and concatenation.
int[] a, c;
// insert
c = a.insert(b, 10);
c = a[0..10] ~ b ~ a[10..$];
// delete
c = a.delete(&a[10..20]);
c = a[0..10] ~ a[20..$];
I essence delete and insert are just another way of expressing slices and
concatenations. Personally I prefer slicing and concatting stuff, because
it expresses better what's actually happening.
Delete and Insert on the other hand are higher level and generally more
intuitive. They leave optimization to the compiler/library. And I think
most D-users like more control of optimizations than users of more high
level languages.
Cheers,
Boyd
---------
On Mon, 12 May 2008 06:11:35 +0200, Saaa <empty at needmail.com> wrote:
> I won't go into the being superior part, but why hasn't anybody asked
> about
> delete and inserts before? (not rhetorical)
> I think slicing and concatenation are fundamental in D.
More information about the Digitalmars-d
mailing list