Destructors can't be @nogc?
Guillaume
first.name at faang.com
Sat Jul 24 10:06:59 UTC 2021
On Saturday, 24 July 2021 at 02:48:51 UTC, Paul Backus wrote:
> Which raises the question, *why* is `destroy` not `@nogc` when
> the destructor is `@nogc`? And it turns out the answer is that
> [it calls `rt_finalize`][1], which [takes its argument as a
> `void*`][2] and therefore has to assume that any destructor it
> calls *might* use the GC.
>
Technically, they might indeed call the GC (if called
deterministically, that is another topic).
If you know it won't happen, you can break the type system like
this:
https://dplug.dpldocs.info/source/dplug.core.nogc.d.html#L80
Which is useful if you are running with some kind of DasWorseD
(no runtime, disabled runtime, or custom runtime usw)
More information about the Digitalmars-d-learn
mailing list