From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id AEF4ABC6B for ; Mon, 10 Dec 2007 21:27:54 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAFowXUfAXQImh2dsb2JhbACPZQEBAQgKKQ X-IronPort-AV: E=Sophos;i="4.24,147,1196636400"; d="scan'208";a="5083117" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 10 Dec 2007 21:27:54 +0100 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id lBAKRsrP015889 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Mon, 10 Dec 2007 21:27:54 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAFowXUdQRFuw/2dsb2JhbAA X-IronPort-AV: E=Sophos;i="4.24,147,1196636400"; d="scan'208";a="5493473" Received: from furbychan.cocan.org ([80.68.91.176]) by mail1-smtp-roc.national.inria.fr with ESMTP; 10 Dec 2007 21:27:54 +0100 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1J1pE2-0005OT-00; Mon, 10 Dec 2007 20:27:38 +0000 Date: Mon, 10 Dec 2007 20:27:38 +0000 To: Oliver Bandel Cc: caml-list@inria.fr Subject: Re: [Caml-list] Ask for a more efficient way to deallocate memory (full version) Message-ID: <20071210202738.GA15084@furbychan.cocan.org> References: <39980.81.57.198.61.1197236388.squirrel@webmail.lpn.cnrs.fr> <95513600712091355j35c4fa65g40bbfce02303796a@mail.gmail.com> <475D2210.70708@Lpn.cnrs.fr> <1197304401.475d6a51d9c06@webmail.in-berlin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1197304401.475d6a51d9c06@webmail.in-berlin.de> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Miltered: at discorde with ID 475DA14A.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 0100,:01 bandel:01 ocaml:01 foo:01 gc'd:01 descriptors:01 orthogonal:01 10,:98 garbage:01 wrote:01 oliver:01 caml-list:01 functions:01 descriptor:02 external:03 On Mon, Dec 10, 2007 at 05:33:21PM +0100, Oliver Bandel wrote: > Zitat von Fabrice Pardo : > > [...] > > When using these kind of external C functions, > > OCaml seems then less comfortable to the programmer > > than reference counted languages. > > I doubt that reference-count is the reason here. > perl also uses reference count, but Filehandles > and Dirhandles have to be closed with close / closedir. This isn't true. In Perl file handles are closed at the end of a scope if they are no longer used. In other words a Perl-equivalent to this loop will never use more than a single file descriptor: while (true) { open "foo" } Even in a GC'd language which could finalize the file handle you could never be sure when the GC is going to be called so it could use an indefinite number of file descriptors. There is a really good paper on this subject -- how ref counting and garbage collection are orthogonal language concepts -- but I can't find it right now. Rich. -- Richard Jones Red Hat