Is it possible to deinitialize the class without calling the gc?

12345swordy alexanderheistermann at gmail.com
Sat Aug 4 02:21:48 UTC 2018


On Friday, 3 August 2018 at 21:44:55 UTC, Adam D. Ruppe wrote:
>> Is it possible to deinitialize the class without calling the 
>> gc?
>
> Yes, use the .destroy function,
Which is converted to void type when passing the object to 
rt_finalize, which causes to lost all type information. How is 
this a better solution!?

> Child classes have independent destructors which do not need to 
> adhere to the attributes of the parent class destructor,
Why is this an issue? Simply don't call them. There is no reason 
for a child class to adhere to the attribute of an empty 
destructor. If you want to be transparent of the possibility of 
them not being called, then create "destructor_hook".
> and moreover this cannot be detected at compile time when the 
> attributes are processed
Are you telling me that D is incapable of determining the classes 
that is currently inheriting the parent class? That not even 
extern (D) can provide information to the compiler!? Do I need to 
add meta information section to my DIP?

I am not interested in a poor man solution here. This is a 
serious problem that needs addressing. I literally see the usage 
of __.dtor in the standard library! What's worst is that I seen 
sledge hammer approach to this by forcing the destroy function to 
be @nogc! I am not convinced that the upcoming protoObject is 
going to fix this issue given that old Object still exist.


More information about the Digitalmars-d mailing list