== Quote from Bartosz Milewski (bartosz-nos...@relisoft.com)'s article > dsimcha Wrote: > > > > The one thing that I think has been missing from this discussion is, what > > would be > > the alternative if we didn't have this "non-deterministic" reallocation? > > How else > > could you **efficiently** implement dynamic arrays? > In the long run (D3), I proposed using the "unique" type modifier. If an array is unique, the compiler knows that there are no slices to worry about, and it can use in-place reallocation to its heart content. That pretty much solves the performance problem. > In the short run (D2), I would suggest sticking to "reallocate on every extension" semantics (especially in SafeD) and provide a library solution (a la C++ std::vector) where the performance of appending is an issue.
Probably not a bad idea, since: 1. I've concluded that appending to slices simply can't be made both efficient and safe. 2. We'll probably get a std.collections anyhow. 3. If you **really** care about performance, you should only append when you don't know the length in advance. If you know the length, you should always pre-allocate.