Browse thread
Ask for a more efficient way to deallocate memory (full version)
[
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: | Jon Harrop <jon@f...> |
| Subject: | Re: [Caml-list] Ask for a more efficient way to deallocate memory (full version) |
On Monday 10 December 2007 21:15, Gordon Henriksen wrote:
> let finally expr cleanup =
> try
> let result = expr () in
> cleanup ();
> result
> with x ->
> cleanup ();
> raise x
I was asking Pierre Weis about getting "try finally" into OCaml recently. I
think the best work-around is to use a combinator, i.e.:
let try_finally x f g =
...
where "x" gets passed to "f" and "g", so you typically do:
try_finally
(open_in file)
input_line
close_in
which looks nicer. However, I still think this construct (and others) should
be added to the language.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?e