Re: Noob question about structs allocation

2018-10-15 Thread Mike Parker via Digitalmars-d-learn
On Monday, 15 October 2018 at 04:14:24 UTC, IM wrote: What is the effect of calling destroy? - calling the destructor? - deallocating the memory? - both? It calls the destructor. The GC will deallocate the object's memory later. However, you need to be careful about how you use

Re: Noob question about structs allocation

2018-10-15 Thread Laurent Tréguier via Digitalmars-d-learn
On Monday, 15 October 2018 at 04:14:24 UTC, IM wrote: What is the effect of calling destroy? - calling the destructor? - deallocating the memory? - both? IIRC, it only calls the destructor, the GC will decide when to deallocate the memory.

Re: Noob question about structs allocation

2018-10-14 Thread IM via Digitalmars-d-learn
On Monday, 15 October 2018 at 03:33:04 UTC, Basile B. wrote: On Monday, 15 October 2018 at 03:19:07 UTC, IM wrote: I probably used to know the answer to this question, but it's been a long time since I last used D, and I don't remember. Suppose we have: struct S { int num; } Would

Re: Noob question about structs allocation

2018-10-14 Thread Basile B. via Digitalmars-d-learn
On Monday, 15 October 2018 at 03:19:07 UTC, IM wrote: I probably used to know the answer to this question, but it's been a long time since I last used D, and I don't remember. Suppose we have: struct S { int num; } Would allocating an instance on the heap using: S* s = new S; use the GC,

Noob question about structs allocation

2018-10-14 Thread IM via Digitalmars-d-learn
I probably used to know the answer to this question, but it's been a long time since I last used D, and I don't remember. Suppose we have: struct S { int num; } Would allocating an instance on the heap using: S* s = new S; use the GC, or do we have to call destroy() or delete on s