Why do you continue to use D?
Stanislav Blinov
stanislav.blinov at gmail.com
Tue Jun 9 19:10:42 UTC 2020
On Tuesday, 9 June 2020 at 18:57:41 UTC, 12345swordy wrote:
>>> Which in order for that to happen it needs to be virtual
>>> function, not a static function.
>>
>> No, that's also not necessary. You can inherit attributes
>> without making the function defined by the destructor function
>> declaration virtual. __xdtor still needs to be virtual, but
>> that appears to be the case already.
>
> How exactly? By having attributes themselves check the
> attributes for the parent class of the deconstructor?
Attributes can't check anything, they're attributes :) The
compiler should statically check your destructor against those of
members (if any) and a paren't class (which has already gone
through the same check). I.e. you simply shouldn't be allowed to
derive a class that has less strict attributes than the most
strict intersection of the above. If any member has a @nogc
destructor, the class would have to have a @nogc destructor as
well. Same if a parent has a @nogc destructor.
This way would ensure that you could destroy objects of derived
classes even via a reference to base class without violating
attributes, as such class definition simply would not have
compiled.
More information about the Digitalmars-d
mailing list