gc heap
Sam S E
asdf at mailinator.com
Sun Nov 23 14:35:43 PST 2008
Jarrett Billingsley Wrote:
> On Sun, Nov 23, 2008 at 5:02 PM, Sam S E <asdf at mailinator.com> wrote:
> > What is allocated in the gc heap? Just classes? Dynamic/associative arrays? Structs? Only things allocated with new? Do built-in types and structs get deallocated at the end of scope like in C?
> >
>
> Everything that is a reference type (classes, dynamic arrays, AAs) is
> allocated on the heap.
>
> Everything that is a value type (basic types, fixed-size arrays,
> structs) are allocated on the stack and are deallocated when the scope
> is left.
>
> scope references to classes will delete the class they refer to when
> the scope is left. As a special case, a declaration of the form
> "scope x = new ClassType()" will actually allocate the class instance
> on the stack instead of on the heap.
Thank you; thanks to you I now have a basic understanding of all the features of D. Now if only Walter could implement all of them :)
--Sam
More information about the Digitalmars-d-learn
mailing list