destructors and GC again
Lutger
lutger.blijdestijn at gmail.com
Mon Oct 16 07:36:52 PDT 2006
Sorry for this topic again, I'm still not exactly sure: when an
unreferenced object is collected during the lifetime of your program
(before main exits), is the destructor of this object guaranteed to be
called? I expect it to be so, as otherwise destructors seem pretty
useless (and dangerous), but cannot infer this from the spec.
The spec says: "The garbage collector is not guaranteed to run the
destructor for all unreferenced objects ... The garbage collector calls
the destructor function when the object is deleted."
It's not clear from this to me that IF an object is collected (of which
you cannot be sure, ok), what is guaranteed about the destructor. I
assume 'deleted' in the spec means that delete is explicitly called, not
'collected by the GC'.
More information about the Digitalmars-d-learn
mailing list