From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA15402 for caml-redistribution; Sun, 16 Jan 2000 22:33:33 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA00819 for ; Sun, 16 Jan 2000 20:34:13 +0100 (MET) Received: from ruby (scratchy12.zip.com.au [61.8.12.140]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id UAA10798 for ; Sun, 16 Jan 2000 20:34:04 +0100 (MET) Received: from maxtal.com.au (IDENT:root@localhost [127.0.0.1]) by ruby (8.9.3/8.9.3) with ESMTP id AAA05600 for ; Mon, 17 Jan 2000 00:17:39 +1100 Sender: weis Message-ID: <3881C4F1.199E96A8@maxtal.com.au> Date: Mon, 17 Jan 2000 00:17:37 +1100 From: skaller Organization: Maxtal X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.12 i586) X-Accept-Language: en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Finalisers References: <200001160136.MAA04210@ruby> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Short note to David: in ocaml 2.999 [with Gc.finalise function]: > > I have used Gc.finalise in Viper to implement __del__ methods. > A short test (create an instance of a python class with a __del__ > method, then forget it) worked correctly. Thoughts: > Suppose there are two objects, A and B, with a pointer > in A to B but not vice versa. > Suppose A becomes globally unreachable (and suppose > B is thereby also unreachable). > > It is important to run the finaliser for A before > the finaliser for B in this case, since the finaliser > for A can refer to B: B is reachable from A. > Indeed, in Python's reference counting scheme, > this behaviour is guarranteed. > > Interscript _requires_ that this ordering apply > to finalisation. In particular, when a weaver object > is finalised, it generates the table of contents > of some document, the output goes to file objects. > It is important the file objects are not finalised > until _after_ the weaver object has generated > the table of contents. > > In general, if A and B become unreachable, and there > is a pointer from A to B, but not from B to A, > then the finaliser of A must be run to completion > before the finaliser for B is invoked. > > This rule cannot be applied when there is a circular dependency: > in that case, one can consider that it would be a programming > error on the client's part to write finalisers that depended > on the 'other' object's unfinalised state. [Since application > of the rule would deadlock the finalisers, and neither > would run -- leaving garbage around] > > It is NOT clear to me why interscript would core dump > if these semantics were not provided: it would fail > to operate correctly (generate wrong output), but not crash. -- John (Max) Skaller, mailto:skaller@maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 homepage: http://www.maxtal.com.au/~skaller download: ftp://ftp.cs.usyd.edu/au/jskaller