Browse thread
[Caml-list] GC and file descriptors
-
Dustin Sallings
- David Fox
- Nicolas George
- Mikael Brockman
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ 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 <bhurt@spnz.org> 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? http://caml.inria.fr/archives/200212/msg00132.html What is the problem with them? - Dmitry Bely ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners