Re: "ocaml_beginners":: System handles
- On 12/26/2012 07:15 PM, Philippe Veber wrote:
> Hi JeffReally amazing this In_channel.with_file. So clean!
> 2012/12/25 Jeff Massung <massung@... <mailto:massung%40gmail.com>>
> > Does Ocaml auto-reclaim (and close) system handles for things like files,
> > mutexes, sockets, etc?
> Following the tutorial on garbage collection (
> http://ocaml.org/tutorials/garbage_collection.html), this is not the case
> for channels, so I'm not confident for the others.
> > If not, is there a way for me to discover that an object is being
> > and do this myself?
> please have a look at [Gc.finalise] (
> http://caml.inria.fr/pub/docs/manual-ocaml/libref/Gc.html) it should do
> what you're looking for.
> That said, I live a better life now that I use the "with_ressource"-like
> functions like Core's [In_channel.with_file] or Batteries
> [File.with_file_in] for resource management. But maybe they are not
> flexible enough for your use case, I'm just saying :o)
> [Non-text portions of this message have been removed]