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 TAA06331 for caml-redistribution; Sat, 28 Aug 1999 19:27:39 +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 JAA14466 for ; Fri, 27 Aug 1999 09:14:02 +0200 (MET DST) Received: from nenuphar.saclay.cea.fr (nenuphar.saclay.cea.fr [132.166.192.7]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id JAA08628 for ; Fri, 27 Aug 1999 09:14:01 +0200 (MET DST) Received: from muguet.saclay.cea.fr (muguet.saclay.cea.fr [132.166.192.6]) by nenuphar.saclay.cea.fr (8.9.1a/8.9.1/CEAnet-relay-5.0.D20) with ESMTP id JAA23659 for ; Fri, 27 Aug 1999 09:13:56 +0200 (MET DST) Received: from harpie.saclay.cea.fr (harpie.saclay.cea.fr [132.166.133.152]) by muguet.saclay.cea.fr (8.9.1a/8.9.1/CEAnet-relay-5.1.D20) with ESMTP id JAA24909; Fri, 27 Aug 1999 09:13:51 +0200 (MET DST) Received: by harpie.saclay.cea.fr (8.8.8+Sun/CEANET.2.0.1) id JAA03104; Fri, 27 Aug 1999 09:13:52 +0200 (MET DST) From: STARYNKEVITCH Basile MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Message-ID: <14278.15024.193052.853437@gargle.gargle.HOWL> Date: Fri, 27 Aug 1999 09:13:52 +0200 (MET DST) To: John Skaller CC: caml-list@inria.fr Subject: Re: GC with finalisation? In-Reply-To: <3.0.6.32.19990824133643.009a89a0@mail.triode.net.au> References: <3.0.6.32.19990824133643.009a89a0@mail.triode.net.au> X-Mailer: VM 6.72 under Emacs 20.4.1 Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit Sender: weis >>>>> "John" == John Skaller writes: John> I could use some advice on this. I'm implementing a Python John> interpreter/compiler in Ocaml. Python class instances John> support __del__ methods -- that is, destructors. 3 choices are then proposed. I suggest a fourth one: 4) patch the existing ocaml 2.02 garbage collector to allow finalized objects containing (for example) a single Ocaml value: this is not very difficult; you'll have to create a new tag, i.e. add #define Finalwithvalue_tag 249 to mlvalues.h then grep for Final_tag in the source, and add the case for Finalwithvalue_tag (which should handle as value its second word after the header, the first being the finalizer). Notice that ocaml finalizer (including those alreday provided thru Final_tag) should *not* allocate any value in the Ocaml heap (in contrast with Java finalizers). Your python finalizer could, for example, add the just finalized Python object to a list -which is malloc-ed and free-d in C- (or perhaps send it on a pipe to yourself) which should be scanned at appropriate moments. On the other hand, I consider that finalized objects supported by the language (such as provided by Java & Python) are a mistake. In my opinion, finalized objects should not have a user-provided finalizer, but should only deal with system resources (file descriptors, X11 windows, coded only in C) N.B. Any opinions expressed here are only mine, and not of my organization. N.B. Les opinions exprimees ici me sont personnelles et n engagent pas le CEA. --------------------------------------------------------------------- Basile STARYNKEVITCH ---- Commissariat à l Energie Atomique DTA/LETI/DEIN/SLA * CEA/Saclay b.528 (p111f) * 91191 GIF/YVETTE CEDEX * France phone: 1,69.08.60.55; fax: 1.69.08.83.95 home: 1,46.65.45.53 email: Basile point Starynkevitch at cea point fr