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 TAA02091 for caml-redistribution; Fri, 4 Feb 2000 19:43:50 +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 TAA06024 for ; Fri, 4 Feb 2000 19:36:10 +0100 (MET) Received: from ruby (wendy56.zip.com.au [61.8.18.56]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id TAA29519; Fri, 4 Feb 2000 19:36:01 +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 FAA03917; Sat, 5 Feb 2000 05:36:21 +1100 Sender: weis Message-ID: <389B1C24.E0A3055F@maxtal.com.au> Date: Sat, 05 Feb 2000 05:36:20 +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: Damien Doligez CC: caml-list@inria.fr Subject: Re: finalisation References: <200002041627.RAA17717@tobago.inria.fr> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Damien Doligez wrote: > > >From: skaller > If python specifies reference counting, I guess the only solution is > to implement reference counting. Python specifically _doesn't_ specify reference counting, it specifies garbage collection. But the current implementation is deficient in that it uses reference counting. So I need to be compatible with existing programs at least as far as preserving their correctness provided only that doesn't depend on synchronous finalisation (a delay is OK, a change of order may not be). >You can use O'Caml's finalisers to > help you in the following way: > > Add a reference count field to each finalisable object. Initialise it > to 1 upon allocation and register a finalisation function for this > object. Increment the reference count when you create a new reference > from another finalised object, and decrement it when you remove a > reference (you can do it by simply calling its finalisation function). I'm not sure how this works .. a reference from a finalised object to another can be indirect (via another object). I'd like to avoid the cost of maintaining reference counts for non-finalisable objects. -- 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