How to call destroy() in @nogc?

Adam Ruppe destructionator at gmail.com
Tue May 24 14:20:45 UTC 2022


On Tuesday, 24 May 2022 at 14:11:57 UTC, Steven Schveighoffer 
wrote:
> Note it has no idea what the real object type is at this point, 
> just that it is an Object (which does not have a @nogc 
> destructor).

It actually has nothing to do with Object. It doesn't have a 
destructor at all, so there's no problem calling it from any 
context.

The real problem is that destructors don't actually use the 
virtual machinery and call super(), meaning it is impossible to 
tell at compile time what they're doing at all.

I know I wrote at length about this somewhere but can't find it 
right now. Probably in the chatroom. But even if you know static 
type, you can't make assumptions about the dynamic type since 
destructors (for no good reason tbh) don't follow the same rules 
as other virtual methods, despite the spec saying they are 
virtual.


More information about the Digitalmars-d-learn mailing list