Article View: comp.lang.clos
Article #369destructors in CLOS?
From: Jon L White
Date: Mon, 24 Dec 1990 22:16
Date: Mon, 24 Dec 1990 22:16
31 lines
2061 bytes
2061 bytes
re: This registration is easy to do with make-instance/initialize-instance,
but any such registration procedure has the problem that
registration/deregistration pairs are an unending source of errors in
C programs that use malloc/free. The problem is similar. The problem
with a destructor is that it is unclear when a "standard"
destructor/finalizer should operate.
One of the reasons I sent such a lengthy reply to the original message
was to alert readers to the danger of thinking that "finalization" and
"destructoring" were one and the same. Indeed, as you point out, a major
source of insidious errors in C programs can be the premature destruction
of non-"dead" data. However, the basic problem is NOT the pairing of
"registration/deregistration" actions [your term], but rather the inability
of the C programmer ever to be assured that some data structure beyond his
immediate control isn't referencing the "dead-meat" datum. The beauty of GC
is that "pairing" can be maintained accurately and automatically.
re: Are explicit make/destroy pairs (with all
their problems) the best we can do in general?
No. Explicit, paired make/destroy actions can be done in any primitive
language (even FORTRAN?). But languages with pre-existing automated memory
management -- such as the Lisp family, SmallTalk, APL, and a handful of
others -- can *offer* one bit of information to the destructor client that
wouldn't otherwise easily be obtainable, namely that no other program data
structure references this object. That is the essence of "finalization."
-- JonL --
Technical Details
Message-ID:
<9012242216.AA08402@caligula>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!LUCID.COM!jonlReferences:
<9012241653.AA00692@zaphod.lanl.gov.lanl.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!LUCID.COM!jonl From: jonl@LUCID.COM (Jon L White) Newsgroups: comp.lang.clos Subject: destructors in CLOS? Message-ID: <9012242216.AA08402@caligula> Date: 24 Dec 90 22:16:18 GMT References: <9012241653.AA00692@zaphod.lanl.gov.lanl.gov> Sender: welch@tut.cis.ohio-state.edu Distribution: inet Organization: CommonLoops Lines: 31