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=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 16043BC0B for ; Mon, 15 Jan 2007 23:28:15 +0100 (CET) Received: from hades.snarc.org (hades.snarc.org [212.85.152.11]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l0FMSEEJ015238 for ; Mon, 15 Jan 2007 23:28:14 +0100 Received: by hades.snarc.org (Postfix, from userid 1000) id 4B5851B481; Mon, 15 Jan 2007 23:27:36 +0100 (CET) Date: Mon, 15 Jan 2007 23:27:36 +0100 To: Daniel =?iso-8859-1?Q?B=FCnzli?= Cc: caml-list@yquem.inria.fr Subject: Re: Try finally (was Re: [Caml-list] Ocaml compiler features) Message-ID: <20070115222736.GB9982@snarc.org> References: <45A87011.8080203@gmail.com> <20070115000544.GA28731@snarc.org> <200701152130.44615.jon@ffconsultancy.com> <81E583BC-438F-41C7-A940-6DF083763845@epfl.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <81E583BC-438F-41C7-A940-6DF083763845@epfl.ch> X-Warning: Email may contain unsmilyfied humor and/or satire. User-Agent: Mutt/1.5.13 (2006-08-11) From: tab@snarc.org (Vincent Hanquez) X-Miltered: at discorde with ID 45ABFFFE.004 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 compiler:01 0100,:01 bunzli:01 pervasives:01 remy's:01 exn:01 exn:01 trivial:01 ocaml:01 cheers:01 unix:01 wrote:01 caml-list:01 slightly:02 On Mon, Jan 15, 2007 at 11:13:58PM +0100, Daniel Bünzli wrote: > A less invasive alternative would be to add something like this to > pervasives (taken from Leroy and Rémy's unix course [1]) : > > let apply f x ~finally y = > let res = try f x with exn -> finally y; raise exn in > finally y; > res > > The only quirk is that when you need to introduce a local or > anonymous function for the blocks, but I don't really care about that. > > However I'm tired of copying this function over and over in my io > intensive sources. This is exactly my point. I have this kind of trivial function spread over and over again. and lots of people have this function as well, maybe a bit different, slightly imcompatible with each other. Coding with OCaml would be some much easier if all those trivia would come directly with the STANDARD distribution. and it would be much more consistant across 2 differents developers as well. Cheers, -- Vincent Hanquez