Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "David McClain" <dmcclain@azstarnet.com>
To: <caml-list@inria.fr>
Subject: Re: unwind-protect?
Date: Fri, 17 Nov 2000 07:37:36 -0700	[thread overview]
Message-ID: <004301c050a3$eea3d6e0$210148bf@dylan> (raw)

>Is there an equivalent of Lisp's `unwind-protect' or Java's
>"try...finally"?

Here is the version that I use. It expects two functions of no arguments --
one for the protected portion and one for cleanup that is invoked in any
event.

let unwind_protect fn exitfn =
  let rslt =
    try
      fn()
    with
 exn ->
   ignore(exitfn());
   raise exn
  in
    ignore(exitfn());
    rslt


- D.McClain




             reply	other threads:[~2000-11-19 14:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-17 14:37 David McClain [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-11-17 14:01 unwind-protect? Damien Doligez
2000-11-21  9:36 ` unwind-protect? Pierre Weis
2000-11-17  6:23 unwind-protect? Colin Walters
2000-11-17 12:28 ` unwind-protect? Pierre Weis
2000-11-17 13:54   ` unwind-protect? CREGUT Pierre FTRD/DTL/LAN

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='004301c050a3$eea3d6e0$210148bf@dylan' \
    --to=dmcclain@azstarnet.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox