SAOC 2021 Projects Summarized
Paul Backus
snarwin at gmail.com
Wed Sep 1 18:20:59 UTC 2021
On Monday, 30 August 2021 at 16:12:57 UTC, Adam D Ruppe wrote:
> On Monday, 30 August 2021 at 16:03:29 UTC, Guillaume Piolat
> wrote:
>> Hyped by ProtoObject, this is our hope for a nothrow @nogc
>> .destroy eventually!
>
> This fails today only because of the rt_finalize hook working
> through void*. If you cut that out...
>
> ---
> class Foo {
> ~this() @nogc nothrow {}
> }
>
> void main() @nogc nothrow {
> scope auto foo = new Foo();
> foo.__xdtor();
> }
> ---
>
> this works today.
I thought the problem with this was that destructors aren't
virtual, so if you write something like this:
---
class Foo {
~this() { }
}
class Bar : Foo {
~this() { }
}
void main() {
Foo foo = new Bar();
foo.__xdtor;
}
---
...then you end up calling Foo's destructor, but not Bar's.
That's why rt_finalize uses TypeInfo to look up the destructor
for the object's runtime type.
More information about the Digitalmars-d-announce
mailing list