From: STARYNKEVITCH Basile <Basile.Starynkevitch@cea.fr>
Date: Fri, 27 Aug 1999 09:13:52 +0200 (MET DST)
To: John Skaller <skaller@maxtal.com.au>
Subject: Re: GC with finalisation?
In-Reply-To: <3.0.6.32.19990824133643.009a89a0@mail.triode.net.au>
>>>>> "John" == John Skaller <skaller@maxtal.com.au> 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
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:24 MET