digitalmars.D.learn - What does nogc do to a class?
- Jack (2/2) May 05 2021 Does it allocate the object rather on stack, like auto scope a =
- Mike Parker (5/7) May 05 2021 It doesn't do anything to classes. `@nogc` prevents you from any
- Jack (2/10) May 06 2021 I see, thanks!
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (5/7) May 06 2021 Further note that
- Jack (2/9) May 08 2021 I'll be using that, thanks!
Does it allocate the object rather on stack, like auto scope a = new A or what?
May 05 2021
On Thursday, 6 May 2021 at 01:04:02 UTC, Jack wrote:Does it allocate the object rather on stack, like auto scope a = new A or what?It doesn't do anything to classes. ` nogc` prevents you from any action triggers a GC allocation, such as using `new, so you would need to allocate from somewhere else (e.g., via `malloc`) for any class instances you want to create in a ` nogc` function.
May 05 2021
On Thursday, 6 May 2021 at 02:11:27 UTC, Mike Parker wrote:On Thursday, 6 May 2021 at 01:04:02 UTC, Jack wrote:I see, thanks!Does it allocate the object rather on stack, like auto scope a = new A or what?It doesn't do anything to classes. ` nogc` prevents you from any action triggers a GC allocation, such as using `new, so you would need to allocate from somewhere else (e.g., via `malloc`) for any class instances you want to create in a ` nogc` function.
May 06 2021
On Thursday, 6 May 2021 at 01:04:02 UTC, Jack wrote:Does it allocate the object rather on stack, like auto scope a = new A or what?Further note that auto scope a = new A; can be written shorter as scope a = new A;
May 06 2021
On Thursday, 6 May 2021 at 22:16:04 UTC, Per Nordlöw wrote:On Thursday, 6 May 2021 at 01:04:02 UTC, Jack wrote:I'll be using that, thanks!Does it allocate the object rather on stack, like auto scope a = new A or what?Further note that auto scope a = new A; can be written shorter as scope a = new A;
May 08 2021