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-09 (22:30)
From: Marcin 'Qrczak' Kowalczyk <qrczak@k...>
Subject: Re: [Caml-list] Re: exception safety / RAII ?
Stefan Monnier <> writes:

> Having a GC gives you a freedom when designing an API that is completely
> incomparable to the minor convenience of not having to explicitly
> close files.  Compare the success of C++ destructors to deal with
> file-closing and the insufficiency of those same destructors to deal with
> object deallocation (leading to the never ending use of reference counting
> and/or explicit copying).

The fact that GC is useful for freeing memory doesn't imply that we
should have no convenient way for closing files.

IMHO there should be something similar to C# 'using', especially given
that the GC will not close dropped files.

The current semantics of C# 'using' is not enough in the presence
of asynchronous exceptions. If OCaml wants to ever have reliable
asynchronous exceptions, its 'using' should have three distinguished
parts: acquire the resource, use it, and release it.

   __("<         Marcin Kowalczyk