From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E07BEBC48 for ; Wed, 9 Mar 2005 16:13:38 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j29FDcp8005965 for ; Wed, 9 Mar 2005 16:13:38 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA17101 for ; Wed, 9 Mar 2005 16:13:37 +0100 (MET) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j29FDarD005953 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Wed, 9 Mar 2005 16:13:37 +0100 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1D92ew-0003gL-84 for caml-list@inria.fr; Wed, 09 Mar 2005 15:59:38 +0100 Received: from ottawa-hse-ppp4097345.sympatico.ca ([70.49.82.164]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 09 Mar 2005 15:59:37 +0100 Received: from monnier by ottawa-hse-ppp4097345.sympatico.ca with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 09 Mar 2005 15:59:37 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Stefan Monnier Subject: Re: exception safety / RAII ? Date: Wed, 09 Mar 2005 09:48:33 -0500 Message-ID: <87zmxc99g5.fsf-monnier+gmane.comp.lang.caml.inria@gnu.org> References: <293072a520e3724a0497e6456a8675be@mac.com> <200503071330.49084.jon@jdh30.plus.com> <87oedvcypd.fsf-monnier+gmane.comp.lang.caml.inria@gnu.org> <200503071710.52544.jon@jdh30.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: ottawa-hse-ppp4097345.sympatico.ca User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:3n0sCec986CAwfzrIp9qeSDaA6g= Sender: news X-Gmane-MailScanner: Found to be clean X-Gmane-MailScanner: Found to be clean X-MailScanner-From: gclci-caml-list@m.gmane.org X-MailScanner-To: caml-list@inria.fr X-Miltered: at concorde with ID 422F12A2.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 422F12A0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; umontreal:01 finalizer:01 finalizer:01 subjective:01 subjective:01 high-level:01 externally:01 trivial:01 contrast:01 exception:01 arbitrary:01 short:01 tracing:01 explicitly:01 rarely:02 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: >> > I very rarely have problems with this. >> Very rarely having problems with something can't save it from being >> a very bad practice. Not explicitly closing your files is (in 99% of the >> cases) just sloppy coding. > If we're talking about programs which are expected to run for an arbitrary > amount of time (servers, the top-level etc.) then yes. This logic is routinely used in C to simply never call `free' because they only run for a short time. That's a textbook example of "sloppy coding". >> Kinda like letting a GC finalizer close your windows: when the effect is >> visible from outside the process it shouldn't be done in a finalizer. > The term "visible" in this context is subjective. I wouldn't call it "subjective", but it is indeed relative to a set of assumptions about what is "visible" and what isn't. My assumptions here are generally that CPU-time and swap-space use are "invisible". The CPU-time part is mostly intrinsic in the fact that I write in a high-level language on top of a multiuser OS and don't have any direct control over the actual assembly code generated, nor over the scheduling decisions. The swap-space part is a basic assumption of a tracing GC. They're not ideal assumptions, but without them life is a lot more difficult. In contrast "the content of my file when another NFS client tries to read it 20 seconds after I generated it (and got an ocamltop prompt back indicating it'd been generated)" is something that I do consider as "externally visible" because it doesn't make life much more difficult: just close the file when you're done with it. It's extremely rare that the point in the code where a file can be closed is not trivial to find. Stefan