Browse thread
Re: unwind-protect?
- David McClain
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | David McClain <dmcclain@a...> |
| Subject: | Re: unwind-protect? |
>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