struct destructors

Sean Kelly sean at invisibleduck.org
Mon May 9 14:04:49 PDT 2011


On May 9, 2011, at 12:51 PM, Alexander wrote:

> On 09.05.2011 19:38, Sean Kelly wrote:
> 
>> Not currently.  I thought I wrote some explanation of why...
> 
>  OK, thanks - I've read the ticket. Though, the problem can be solved relatively simple, IMHO - adding one more pointer to BlkInfo, where address of the finalizer is stored, which will be used only for cases when collected object is not a class.

Well... BlkInfo is generated from a selection of internal sources.  You're right that the GC would need to store a finalizer reference for structs, but that's just the simple case.  It would also need to finalize structs in dynamic arrays and AA nodes as well (though it's possible the latter already works, since the AA is now template code).  And of course the finalizer reference would have to be passed to GC.malloc() or whatever so that portion of the API would change as well.  I originally held off on fixing this because its requirements seemed to fit nicely with the requirements for precise scanning (ie. passing the GC some TypeInfo so it can be smarter about how it deals with allocated memory blocks in general), and I wanted to do both at once.  But I have a feeling that I came up with some other problem regarding struct finalization, so I want to see if I can find that old email or whatever to be sure.


More information about the Digitalmars-d mailing list