Version franaise
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: Quc_Peyrot <chojin@l...>
Subject: Re: Try finally (was Re: [Caml-list] Ocaml compiler features)

On Jan 15, 2007, at 2:27 PM, Vincent Hanquez wrote:

> On Mon, Jan 15, 2007 at 11:13:58PM +0100, Daniel Bnzli wrote:
>> A less invasive alternative would be to add something like this to
>> pervasives (taken from Leroy and Rmy'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.

I don't know for the other trivial functions, but this apply function  
looks like
Std.finally from extlib.

I hardly miss any trivial functions when using extlib, mileage might  
vary.

-- 
Best Regards,
Quc