From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA17613; Sat, 15 Nov 2003 16:56:32 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 QAA16956 for ; Sat, 15 Nov 2003 16:56:30 +0100 (MET) Received: from oxy.exomi.com (ua199d87hel.dial.kolumbus.fi [212.54.23.199]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hAFFuP121005; Sat, 15 Nov 2003 16:56:27 +0100 (MET) Received: by oxy.exomi.com (Postfix, from userid 501) id 89F46B0087; Sat, 15 Nov 2003 17:56:18 +0200 (EET) Date: Sat, 15 Nov 2003 17:56:17 +0200 From: Ville-Pertti Keinonen To: skaller Cc: Dustin Sallings , Damien Doligez , Caml Mailing List Subject: Re: [Caml-list] GC and file descriptors Message-ID: <20031115155617.GA592@exomi.com> Mail-Followup-To: skaller , Dustin Sallings , Damien Doligez , Caml Mailing List References: <70D8AC5D-16A8-11D8-BFCA-00039310CAE8@inria.fr> <4A73AF35-16D1-11D8-9BF4-000393CFE6B8@spy.net> <1068905767.25869.130.camel@pelican> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1068905767.25869.130.camel@pelican> User-Agent: Mutt/1.4.1i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 1100,:01 orderly:01 python:01 finalization:01 cyclic:01 cyclic:01 finalization:01 fallback:01 liveness:01 liveness:01 ocaml:01 ocaml:01 garbage:01 lisp:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, Nov 16, 2003 at 01:16:08AM +1100, skaller wrote: > It is possible to modify the Ocaml collector to make finalisation > orderly, but it is very expensive. It is also possible Not just expensive, more like something you definitely don't want to even try. Python tries to have deterministic finalization, but falls back on "normal" garbage collection for containers (with potential cyclic references). Perl doesn't even bother with that, instead it doesn't resolve cyclic references at all. Typically, the best you can do is explicit finalization; which can be convenient using something similar to Lisp with-open-file constructs, possibly with alternate interfaces and finalization on GC as a fallback for poorly structured programs. For more complicated cases with multiple references, what you probably want is an explicit liveness count (separate from the GC/memory references). The liveness count can likewise be protected by something similar to unwind-protect blocks. Considering that OCaml doesn't have capturable continuations, things are relatively simple. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners