Allocating structs with new?
Leandro Lucarella
luca at llucax.com.ar
Sat Jul 10 15:17:21 PDT 2010
Robert Jacques, el 10 de julio a las 02:31 me escribiste:
> As for the bug, it's actually somewhat old. Issue 2834 was filed
> back in April of 09 - Struct Destructors are not called by the GC,
> but called on explicit delete. And this is a bug in the spec, not
> DMD; the only way to run struct destructors from the GC is to add
> vtables to them or hidden in the GC (i.e. to make them classes).
You don't need a vtable, because you don't have inheritance with
structs. All you need is a function pointer pointing to the finalization
function/method. This plays well with the concept of having type
information associated to blocks of memory in the GC, which means
(semi)precise heap scanning. So maybe is not a bad idea to make the
destructors of structs get called by the GC :)
--
Leandro Lucarella (AKA luca) http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Debemos creer en los sueños del niño. Cuando el niño sueña con tetas, se
toca.
-- Ricardo Vaporeso. Toulouse, 1915.
More information about the Digitalmars-d
mailing list