From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA02382 for caml-redistribution; Thu, 26 Aug 1999 19:29:42 +0200 (MET DST) 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 FAA08920 for ; Tue, 24 Aug 1999 05:35:16 +0200 (MET DST) Received: from iggy.triode.net.au ([203.63.235.1]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id FAA29367 for ; Tue, 24 Aug 1999 05:35:13 +0200 (MET DST) Received: from egret (pm1-17.triode.net.au [203.63.235.33]) by iggy.triode.net.au (8.9.3/8.8.8) with SMTP id NAA27414 for ; Tue, 24 Aug 1999 13:31:04 +1000 Message-Id: <3.0.6.32.19990824133643.009a89a0@mail.triode.net.au> X-Sender: skaller@mail.triode.net.au X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Tue, 24 Aug 1999 13:36:43 +1000 To: caml-list@inria.fr From: John Skaller Subject: GC with finalisation? Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: weis I could use some advice on this. I'm implementing a Python interpreter/compiler in Ocaml. Python class instances support __del__ methods -- that is, destructors. CPython uses reference counting for collection and finalisation. JPython leverages Java's collector and finalisation semantics. My current ocaml implementation leverages the ocaml collector, which doesn't support finalisation (as far as I know). I seem to have several choices. 1) implement reference counting for finalisation * disadvantage: same problem as CPython: doesn't resolve circular references properly * disadvantage: overhead and coding complexity * advantage: synchronous finalisation 2) Implement a full resource collector * disadvantage: overhead and complexity * disadvantage: probably won't support synchronous finalisation 3) provide BOTH reference counting and a collector (as Perl does) * disadvantage: overhead and complexity * advantage: finalises everything * advantage: synchonous finalisation in all cases that CPython provides it I am interested in any comments on how to solve this problem. Order of finalisation can be important in Python. I have a major literate programming tool (Interscript) written in Python, the compiler/interpreter is being built to make it go faster. I use finalisation semantics extensively (tables of information are generated at the end of document processing, etc). While I might be able to rewrite it to avoid automatic finalisation, it would be nice to support the wide class of other Python programs that rely on it. ------------------------------------------------------- John Skaller email: skaller@maxtal.com.au http://www.maxtal.com.au/~skaller phone: 61-2-96600850 snail: 10/1 Toxteth Rd, Glebe NSW 2037, Australia