On Wednesday, 30 July 2014 at 09:52:15 UTC, Andrew Godfrey wrote:
What about T[] is _not_ a dynamic array?
Now that I've done this exercise I can answer more crisply:
When T[] is an lvalue, it behaves like a reference, not a
dynamic array.
So the fact that it slices rather than copies is enough to make
it not a dynamic array. As far as I can tell, the copying
behavior of a dynamic array has nothing to do with it being a
dynamic array. It's the facts that you can append to, it
maintains extra capacity to make appending efficient, and it
reallocates when it runs out of extra capacity (making appending
an amortized O(1)) that make an array a dynamic array. And T[]
does that.
- Jonathan M Davis