Zachary Lund admin at computerquip.com
Mon Feb 13 18:41:01 PST 2012

On 02/11/2012 07:00 PM, Jonathan M Davis wrote:
> On Sunday, February 12, 2012 01:40:50 Zachary Lund wrote:
>> Btw, I'm not very fluent in the inner workings of a garbage
>> collector implementation but how does one go about concatenating
>> to an array in a garbage collector as compared to manual memory
>> management? I believe array concatenation can be done in
>> std::vector with the insert() function just fine. Isn't it as
>> simple as determining both array sizes and allocating enough
>> memory for both arrays? I could be oversimplifying things...
> Read this:
> http://www.dsource.org/projects/dcollections/wiki/ArrayArticle
> Appending to vectors is very different from appending to dynamic arrays because
> dynamic arrays do _not_ own their own memory (the GC does) and not only could
> other slices refer the same memory (in which case, you can't just free that
> memory when an array gets reallocated due to running out of space to append
> to), but they could already refer to the memory one past the end of the array,
> making it so that it can't expand into that memory.
> Slices change the entire equation. And the way slices are designed, they
> require the GC.
> - Jonathan M Davis

Right but they use the same semantics and the information to do either 
seems to be present. I'm not sure why an abstraction between the two 
cannot be made.

More information about the Digitalmars-d mailing list