On Tuesday, 6 November 2012 at 09:10:08 UTC, bearophile wrote:
Malte Skarupke:

I will most certainly never use dynamic arrays or slices again for anything that needs to grow or shrink dynamically.

And doing so you will miss an important and handy part of D :-/

Bye,
bearophile

I implemented my own DynamicArray struct which behaves more like I want it to and is still giving me all of the benefits that I want from dynamic arrays.

Having no clear ownership for the array is not something I am willing to accept. Same thing for the non-deterministic copying and destruction behavior for the elements. That's the kind of thing which looks convenient at first, but will create many small performance problems. Once those add up to a big problem, it's incredibly frustrating to fix because your slow downs are from all over the place.

I don't anticipate that I will ever run into a situation where I want to append to a range without caring about whether it allocates and copies or not. If I want to append to a range, I will write the extra line to create a copy manually. Because of that I don't need the syntactic ambiguity of treating a range the same as an array.

Reply via email to