From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA21885 for caml-red; Fri, 17 Nov 2000 13:12:03 +0100 (MET) 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 HAA15674 for ; Fri, 17 Nov 2000 07:27:48 +0100 (MET) Received: from cis.ohio-state.edu (mail.cis.ohio-state.edu [164.107.115.5]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id eAH6Raj02762 for ; Fri, 17 Nov 2000 07:27:45 +0100 (MET) Received: from meta.verbum.org (root@gold.cis.ohio-state.edu [164.107.112.16]) by cis.ohio-state.edu (8.9.1/8.9.1) with ESMTP id BAA15779 for ; Fri, 17 Nov 2000 01:25:55 -0500 (EST) Received: by meta.verbum.org (Postfix (Debian/GNU), from userid 1000) id 51FF21035D; Fri, 17 Nov 2000 01:23:23 -0500 (EST) To: caml-list@inria.fr Subject: unwind-protect? X-Attribution: Colin Organization: The Ohio State University Dept. of Computer and Info. Science Original-Sender: walters+s@cis.ohio-state.edu From: Colin Walters Date: 17 Nov 2000 01:23:23 -0500 Message-ID: <87d7fvruas.church.of.emacs@meta.verbum.org> User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: weis@pauillac.inria.fr Hello, Is there an equivalent of Lisp's `unwind-protect' or Java's "try...finally"? I wanted to write a function which changed to another directory temporarily, and I came up with: let in_directory d f = let olddir = Unix.getcwd() in (Unix.chdir d; f(); Unix.chdir olddir) But this won't work if f throws an exception. Any suggestions?