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 HAA01971; Wed, 30 Jul 2003 07:45:03 +0200 (MET DST) 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 HAA08894 for ; Wed, 30 Jul 2003 07:45:02 +0200 (MET DST) Received: from yukon.yapper.org (adsl-67-120-175-89.dsl.lsan03.pacbell.net [67.120.175.89]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h6U5j0f14597 for ; Wed, 30 Jul 2003 07:45:01 +0200 (MET DST) Received: from kenai.yapper.org (kenai.yapper.org [67.120.175.90]) by yukon.yapper.org (Postfix) with ESMTP id 8D72EA; Tue, 29 Jul 2003 22:44:58 -0700 (PDT) Received: from cs.caltech.edu (localhost [127.0.0.1]) by kenai.yapper.org (Postfix) with ESMTP id 7EEC78131A; Tue, 29 Jul 2003 22:44:58 -0700 (PDT) Message-ID: <3F275B5A.3010301@cs.caltech.edu> Date: Tue, 29 Jul 2003 22:44:58 -0700 From: Jason Hickey Organization: Caltech User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20030211 X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: [Caml-list] unwind-protect References: <4.3.2.7.2.20030728112622.02f3fef8@localhost> In-Reply-To: <4.3.2.7.2.20030728112622.02f3fef8@localhost> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; hickey:01 pragmatic:01 camlp:01 re-raising:01 interfere:01 626:99 792:99 caltech:01 exception:02 stack:02 unit:03 string:03 exn:03 suppose:03 tracing:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk A related, but pragmatic problem. Suppose we have some imperative code, and we need an "unwind-protect" operation. Consider this code to make sure a file is closed after it is used. let with_open_file (name : string) (f : in_channel -> unit) = let inc = open_in name in try f inc; close inc with exn -> close inc; raise exn 1. It would be wonderful to have a "finally" clause, so we don't have to duplicate the close operation. I suppose we can fake it with CamlP4, but it seems better built-in. 2. This kind of exception re-raising does not work well with stack tracing (OCAMLRUNPARAM=b). It would be very nice to add a "finally" clause that did not interfere with stack tracing, or make it so that re-raising would preserve the location where the exception was created. Jason -- Jason Hickey http://www.cs.caltech.edu/~jyh Caltech Computer Science Tel: 626-395-6568 FAX: 626-792-4257 ------------------- 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