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 7B94EBC84 for ; Tue, 8 Mar 2005 19:27:43 +0100 (CET) Received: from ptb-relay02.plus.net (ptb-relay02.plus.net [212.159.14.213]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j28IRhZA001301 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 8 Mar 2005 19:27:43 +0100 Received: from [80.229.56.224] (helo=chetara) by ptb-relay02.plus.net with esmtp (Exim) id 1D8jQk-00062Y-Il for caml-list@yquem.inria.fr; Tue, 08 Mar 2005 18:27:42 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Re: exception safety / RAII ? Date: Tue, 8 Mar 2005 18:28:44 +0000 User-Agent: KMail/1.7.1 References: <293072a520e3724a0497e6456a8675be@mac.com> <877e9a1705030710476502ad31@mail.gmail.com> <1110281592.680.102.camel@localhost> In-Reply-To: <1110281592.680.102.camel@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200503081828.44579.jon@jdh30.plus.com> X-Miltered: at concorde with ID 422DEE9F.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 deallocated:01 afaik:01 verifiers:01 run-time:01 deallocation:01 damien:01 ocaml:01 ocaml:01 finalisers:01 frog:98 wrote:01 wrote:01 exception:01 doligez:01 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: On Tuesday 08 March 2005 11:33, Ville-Pertti Keinonen wrote: > I'm not sure I understand Jon Harrop's concern about using resources > after they've been deallocated. This has been addressed in the obvious > way (return errors for operations on remaining references) in various > languages for decades, and unlike memory management and type errors, > AFAIK hasn't been a major source of bugs or complaints. A great deal of effort has been put into writing static verifiers to ensure correct use, in order to remove this class of run-time errors. So I think this is unquestionably a source of bugs. Could it not be said that having a GC is a way to avoid such errors in the context of memory allocation and deallocation? On Tuesday 08 March 2005 13:07, Damien Doligez wrote: > On Mar 7, 2005, at 18:10, Jon Harrop wrote: > > I believe that OCaml guarantees to close your files at least upon program > > termination, > > OCaml does no such thing. The OS does. Yipes! In that case I take back what I said before and agree with Stefan - it is sloppy coding style to not explicitly close a file. That seems most odd though. Is this for historical reasons - closing files was added long before object finalisers? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. Objective CAML for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists