Destructors can't be @nogc?

Jim jim at mailinator.com
Sun Jul 25 00:15:30 UTC 2021


On Saturday, 24 July 2021 at 10:15:50 UTC, Mike Parker wrote:

> Personally, I think `@nogc` on main is a bad idea. `@nogc` 
> should be used as far down the call stack as you can put it. 
> The higher it is, the more difficulty you're going to run into. 
> I recommend you apply it only on functions that run in the 
> hottest parts of a program. Those are the areas where GC 
> allocations triggering collections can obviously become an 
> issue. So start there.

Alright, I see where you're coming from, and I'm inclined to 
agree.
I'll look into constraining @nogc to performance-critical parts 
of the program.

But I think `destroy()` not being @nogc even though the 
destructor is tagged @nogc is a bug, and it should be fixed. 
Because it is problematic behaviour even if we limit the usage of 
@nogc.


More information about the Digitalmars-d-learn mailing list