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
[Caml-list] GC and file descriptors
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-11-15 (01:49)
From: Dmitry Bely <dbely@m...>
Subject: Re: [Caml-list] GC and file descriptors
Brian Hurt <> writes:

>> close() can fail (generate an exception). How are you going to handle it in
>> the garbage collector? On the contrary, the memory deallocaton always
>> succeeds.
> Two choices: either abort the whole program (uncaught exception), or 
> ignore it.  Ocaml's life is a little easier, as GC takes place inside the 
> single thread of execution.  But I dislike making the language spec 
> require that.  
> Now, *which* of those two choices is "correct" is a matter for some 
> debate.  Myself, I like aborting the whole program.

I think none of them. Imagine that you access a file over the network. Now,
a network error can suddenly terminate your program (you users will be
very surprised) or can be missed that leads to the possible loss of data
(they will be surprised also).

Generally speaking, GC is not suitable for resource deallocation - this
should be done synchroniously (generating and catching exceptions).

> What I dislike is resource leaks- as plugging the holes manually can often
> be tricky.  If I wanted to hand-manage resource deallocation, I'd be
> programming in C (well, not quite- but the point is made).

Why not to use high-order functions?

What is the problem with them?

- Dmitry Bely

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: