auto classes and finalizers - correction
kris
foo at bar.com
Sun Apr 9 13:51:27 PDT 2006
kris wrote:
> I use a bit of a hack to distinguish between the two: a common module
> has a global variable set to true when the enclosing module-dtor is
> invoked. This obviously depends upon module-dtors being first (which
> they currently are, but that is not in the spec). Most of you will
> probably be going "eww" at this point, but it's the only way I found to
> make dtors consistent and thus usable. Further, this is only workable if
> the dtor() itself can be abandoned when in state (b) above; prohibiting
> the use of dtors for a whole class of cleanup concerns, and forcing one
> to defer to the dispose() or close() pattern ~~ some say anti-pattern.
After reading, that paragraph does not reflect the status-quo at all ...
First, it should have said "used" instead of "use" (past-tense ~ this is
not applied any more, since dtors have all but been abandoned). Second,
the identification of "state" was limited to program termination only ~
the classes in question were actually collected only at that point.
Third, the cleanup did not rely on GC managed memory. All in all, that
paragraph is pretty darned misleading ~~ my bad :-(
The take-home message is that I did not find a general mechanism to
distinguish between valid-state and unspecified-state for a dtor ~ the
oft-crucial inconsistency remains in its fully-fledged guise. The other
issue is that I clearly should avoid posting whilst hallucinating.
Sorry;
More information about the Digitalmars-d
mailing list