>>>>> "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