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,SUBJECT_EXCESS_QP autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 2424BBC6B for ; Tue, 11 Dec 2007 00:33:19 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtYjABhcXUfUnw7XYmdsb2JhbACCOI0jFQQGEBk X-IronPort-AV: E=Sophos;i="4.24,148,1196636400"; d="scan'208";a="6679378" Received: from fhw-relay07.plus.net ([212.159.14.215]) by mail3-smtp-sop.national.inria.fr with ESMTP; 11 Dec 2007 00:33:18 +0100 Received: from [80.229.56.224] (helo=beast.local) by fhw-relay07.plus.net with esmtp (Exim) id 1J1s7i-00047j-5B for caml-list@yquem.inria.fr; Mon, 10 Dec 2007 23:33:18 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Ask for a more efficient way to =?iso-8859-15?q?deallocate=09memory?= (full version) Date: Mon, 10 Dec 2007 23:24:08 +0000 User-Agent: KMail/1.9.5 References: <39980.81.57.198.61.1197236388.squirrel@webmail.lpn.cnrs.fr> <20071210202738.GA15084@furbychan.cocan.org> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200712102324.08710.jon@ffconsultancy.com> X-Spam: no; 0.00; expr:01 expr:01 weis:01 ocaml:01 work-around:01 combinator:01 frog:98 wrote:01 caml-list:01 pierre:02 construct:02 deallocate:03 let:03 let:03 raise:03 On Monday 10 December 2007 21:15, Gordon Henriksen wrote: > let finally expr cleanup = > try > let result = expr () in > cleanup (); > result > with x -> > cleanup (); > raise x I was asking Pierre Weis about getting "try finally" into OCaml recently. I think the best work-around is to use a combinator, i.e.: let try_finally x f g = ... where "x" gets passed to "f" and "g", so you typically do: try_finally (open_in file) input_line close_in which looks nicer. However, I still think this construct (and others) should be added to the language. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e