From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA22602; Thu, 12 Dec 2002 01:29:37 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 BAA23308 for ; Thu, 12 Dec 2002 01:29:36 +0100 (MET) Received: from igw3.watson.ibm.com (igw3.watson.ibm.com [198.81.209.18]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gBC0TZX12928 for ; Thu, 12 Dec 2002 01:29:35 +0100 (MET) Received: from sp1n293en1.watson.ibm.com (sp1n293en1.watson.ibm.com [9.2.112.57]) by igw3.watson.ibm.com (8.11.4/8.11.4) with ESMTP id gBC0TPQ23916; Wed, 11 Dec 2002 19:29:25 -0500 Received: from nautilus-chet.watson.ibm.com (sig-9-65-111-216.mts.ibm.com [9.65.111.216]) by sp1n293en1.watson.ibm.com (8.11.4/8.11.4) with ESMTP id gBC0TOg49408; Wed, 11 Dec 2002 19:29:24 -0500 Received: from maine (maine [127.0.0.1]) by nautilus-chet.watson.ibm.com (8.12.5/8.12.5/Debian-1) with ESMTP id gBC0RnTd008495; Wed, 11 Dec 2002 19:27:49 -0500 Message-Id: <200212120027.gBC0RnTd008495@nautilus-chet.watson.ibm.com> To: Brian Hurt cc: Blair Zajac , Caml Users Mailing List Subject: Re: [Caml-list] Resource acquisition is initialization In-Reply-To: Your message of "Wed, 11 Dec 2002 13:55:10 CST." References: Date: Wed, 11 Dec 2002 19:27:49 -0500 From: Chet Murthy Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Blair, Perhaps, what you want is a "try_finally" for Ocaml. E.g. let finally f arg finf = let rv = try Inl(f arg) with e -> Inr e in (try finf arg (match rv with Inl v -> Some v | Inr _ -> None) with e -> ()); match rv with Inl v -> v | Inr e -> raise e Now, while this code isn't the most efficient, I believe (haven't checked the details) that with sufficient partial evaluation and some code-rearranging which is semantics-preserving, this code becomes efficient, albeit somewhat larger than perhaps entirely desirable. --chet-- ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners