Version française
Home     About     Download     Resources     Contact us    
Browse thread
Ocaml compiler features
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: tab@s...
Subject: Re: Try finally (was Re: [Caml-list] Ocaml compiler features)
On Mon, Jan 15, 2007 at 11:13:58PM +0100, Daniel Bünzli wrote:
> A less invasive alternative would be to add something like this to  
> pervasives (taken from Leroy and Rémy's unix course [1]) :
> 
> let apply f x ~finally y =
>   let res = try f x with exn -> finally y; raise exn in
>   finally y;
>   res
> 
> The only quirk is that when you need to introduce a local or  
> anonymous function for the blocks, but I don't really care about that.
> 
> However I'm tired of copying this function over and over in my io  
> intensive sources.

This is exactly my point. 

I have this kind of trivial function spread over and over again.
and lots of people have this function as well, maybe a bit different,
slightly imcompatible with each other.

Coding with OCaml would be some much easier if all those trivia would
come directly with the STANDARD distribution. and it would be much more
consistant across 2 differents developers as well.

Cheers,
-- 
Vincent Hanquez