#dbugfix 17592
Basile B.
b2.temp at gmx.com
Thu Mar 22 21:37:40 UTC 2018
On Thursday, 22 March 2018 at 20:25:28 UTC, jmh530 wrote:
> On Wednesday, 21 March 2018 at 14:04:58 UTC, Adam D. Ruppe
> wrote:
>>
>> In Simen's example, the child information is not available at
>> compile time. This line here:
>>
>> A a = new B();
>>
>> discards the static type. The compiler could probably cheat
>> and figure it out anyway in this example, but suppose:
>>
>> [snip]
>
> There are a few interesting things in the class destructor part
> of the spec.
>
> For instance:
> "There can be only one destructor per class, the destructor
> does not have any parameters, and has no attributes. It is
> always virtual."
Reality is very different. The __ctbl is NOT USED AT ALL to call
the __dtor.
> If the destructor has no attributes, how can it be @nogc?
>
> Also:
> "The destructor for the super class automatically gets called
> when the destructor ends. There is no way to call the super
> destructor explicitly."
Reality is different. One can play with the __dtor member.
This is what i do in IZ.
- `destruct!(MyDerived)(myDerived)`: this has for effect to trust
the static type that's passed to destruct(). That way destruct
can be really @nogc.
- `destruct!(Object)(cast(Object)myDerived)`: this has for effect
to use the dunamic type (i.e with typeid() i get the type info
that contains a pointer to the __dtor, which CANT be @nogc. This
is equivalent to official destroy().
In both case i also use a mixin called `inheritedDtor` which,
contrary to what is stated in the specs, allowd to call
explicitly the super __dtor.
I don't say that's the solution. I think there's no solution.
What i do is not clean. It only works with displine and inside a
particular library.
I'm gonna post a DUB script as POC later.
More information about the Digitalmars-d
mailing list