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 CAA24185; Sat, 15 Nov 2003 02:49:04 +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 CAA24914 for ; Sat, 15 Nov 2003 02:49:03 +0100 (MET) Received: from relay.rinet.ru (relay.rinet.ru [195.54.192.35]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hAF1n2113412 for ; Sat, 15 Nov 2003 02:49:03 +0100 (MET) Received: from relay.rinet.ru (localhost [127.0.0.1]) by relay.rinet.ru (8.12.9p2/8.12.9) with ESMTP id hAF1n3jp061246 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 15 Nov 2003 04:49:03 +0300 (MSK) (envelope-from dbely@mail.ru) Received: (from uucp@localhost) by relay.rinet.ru (8.12.9p2/8.12.9/Submit) with UUCP id hAF1n3CN061245 for caml-list@inria.fr; Sat, 15 Nov 2003 04:49:03 +0300 (MSK) (envelope-from dbely@mail.ru) Received: from dialin1.stormoff (ROVER1) [192.168.0.129] by stormoff with esmtp (Exim 3.12 #1 (Debian)) id 1AKpYP-0000bk-00; Sat, 15 Nov 2003 04:48:50 +0300 X-Comment-To: Brian Hurt To: caml-list@inria.fr Subject: Re: [Caml-list] GC and file descriptors References: From: Dmitry Bely Date: Sat, 15 Nov 2003 04:47:51 +0300 In-Reply-To: (Brian Hurt's message of "Fri, 14 Nov 2003 15:48:27 -0600 (CST)") Message-ID: User-Agent: Gnus/5.090008 (Oort Gnus v0.08) XEmacs/21.4 (Military Intelligence (RC5 Windows), i586-pc-win32) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 abort:01 ocaml's:01 aborting:01 caml:01 garbage:01 dmitry:01 dmitry:01 descriptors:01 writes:01 bely:01 bely:01 catching:02 exception:02 exception:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Brian Hurt writes: >> close() can fail (generate an exception). How are you going to handle it in >> the garbage collector? On the contrary, the memory deallocaton always >> succeeds. > > Two choices: either abort the whole program (uncaught exception), or > ignore it. Ocaml's life is a little easier, as GC takes place inside the > single thread of execution. But I dislike making the language spec > require that. > > Now, *which* of those two choices is "correct" is a matter for some > debate. Myself, I like aborting the whole program. I think none of them. Imagine that you access a file over the network. Now, a network error can suddenly terminate your program (you users will be very surprised) or can be missed that leads to the possible loss of data (they will be surprised also). Generally speaking, GC is not suitable for resource deallocation - this should be done synchroniously (generating and catching exceptions). > What I dislike is resource leaks- as plugging the holes manually can often > be tricky. If I wanted to hand-manage resource deallocation, I'd be > programming in C (well, not quite- but the point is made). Why not to use high-order functions? http://caml.inria.fr/archives/200212/msg00132.html What is the problem with them? - Dmitry Bely ------------------- 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