Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
exception safety / RAII ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-03-08 (21:33)
From: Damien Doligez <damien.doligez@i...>
Subject: Re: [Caml-list] Re: exception safety / RAII ?
On Mar 8, 2005, at 19:28, Jon Harrop wrote:

> That seems most odd though. Is this for historical reasons - closing 
> files was
> added long before object finalisers?

It was done after thinking hard about the question.  The answer is that
the "close" system call has several effects.  Resource deallocation is
one of these effects, but it's not the only one.  So when to close is
almost always a decision that must be made by the programmer, and we
don't want to encourage people to think otherwise.

And it would be ugly to have both explicit (close function) and implicit
(finalizer) closing of a file.

-- Damien