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-07 (02:43)
From: Brian Hurt <bhurt@s...>
Subject: Re: [Caml-list] Re: exception safety / RAII ?
On Sun, 6 Mar 2005, Stefan Monnier wrote:

> > In most cases you probably won't care when a file is closed after writing to
> > it, so you can just rely on the garbage collector.
> Very bad practice in (e.g.) an NFS world where the filesystem makes no
> guarantee about file writes until you actually close the file.

Ocaml does give you the close_out function to explicitly close an I/O 
stream.  Closing on GC collection just catches the odd cases, like exiting 
the function unexpected (via an exception, for example).