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] Resource acquisition is initialization
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-12-11 (19:18)
From: Blair Zajac <blair@o...>
Subject: [Caml-list] Resource acquisition is initialization
One of the nice things about C++ and Java is that with properly
designed classes, you don't need to worry about freeing resources
in complicated code, because the when the objects go out of scope
either normally or via an exception, they will clean themselves up.

Here's a good description of this idiom:

Given that Ocaml has objects, it would be useful to have this
idiom available to us.  Is there a way to implement it, rather
than just waiting for the garbage collector?

Also, since objects have initializers, do they have finializers?  I
read the entire Oreilly book and didn't see any mention of them.

Reading the C code interface, it looks like you can associate a
finalizer function to clean up an abstract type, but can you do
this with normal Ocaml code?


Blair Zajac <>
Plots of your system's performance -
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: