On Friday, 26 May 2017 at 17:08:40 UTC, Igor Shirkalin wrote:
On Monday, 22 May 2017 at 17:05:06 UTC, Stanislav Blinov wrote:
I'd like to hear what you guys think about this issue:

https://issues.dlang.org/show_bug.cgi?id=15246

[...]

If your destructor is not @safe and @nogc, why not to make it be the same or call inherited destructor implicity?

Destructors of derived classes are called implicitly on finalization. The net effect is that such finalization adopts the weakest set of attributes among all the destructors it calls.

There are two sides of this problem: one is that we cannot have deterministic destruction (i.e. manually allocate/free classes) while keeping attribute inference: under current rules, finalization has to be @system. This one can be tackled if the language provided strict rules of attribute inheritance in destructors.

Another side, clearly demonstrated by my second post, is that non-deterministic destruction cannot be @safe, period. Because when GC collects and calls destructors, it calls all of them, regardless of their @safe status, even when the collection is triggered inside a @safe function.

Reply via email to