Is this a bug?

John Colvin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Apr 29 01:36:00 PDT 2014


On Tuesday, 29 April 2014 at 06:13:52 UTC, Andrey wrote:
> Ok, thanks a lot..
>
> About dynamic arrays: I haven't found any information about 
> internal representation of the D structures. E.g. do dynamic 
> arrays have reference counter?
>
> Nevermind, I'm gonna use Type2[0] syntax.

D dynamic arrays (better referred to as slices) can be thought of 
as implmented like

struct Array(T)
{
     T* ptr;
     size_t length;
}

They do not track ownership or have any reference counting. If 
they've been allocated with "new" then the GC will take care of 
them once there are no remaining references to them.


More information about the Digitalmars-d-learn mailing list