Thanks! Just what I needed to understand. :-)
On Thursday, 29 May 2014 at 08:12:10 UTC, Ali Çehreli wrote:
On 05/29/2014 12:37 AM, Sourav wrote:
> the behavior totally depends upon how many
> elements were present initially in the array, which means,
the capacity
> of a slice can actually introduces little surprises in the
code! Is this
> expected behavior or am I entirely missing something here?
It is by design. I tried to explain this behavior under the
section "Making a slice longer may terminate sharing" here:
http://ddili.org/ders/d.en/slices.html
The section "capacity to determine whether sharing will be
terminated" shows a way to detect whether sharing will be
terminated.
Steven Schveighoffer's array article goes into design and
implementation details:
http://dlang.org/d-array-article.html
Ali