Loading ...
Sorry, an error occurred while loading the content.

Re: "ocaml_beginners"::[] System handles

Expand Messages
  • Francois Berenger
    ... Really amazing this In_channel.with_file. So clean!
    Message 1 of 4 , Dec 26, 2012
    • 0 Attachment
      On 12/26/2012 07:15 PM, Philippe Veber wrote:
      > Hi Jeff
      >
      > 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
      > finalized
      > > 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)

      Really amazing this In_channel.with_file. So clean!

      > Cheers,
      > Philippe.
      >
      > [Non-text portions of this message have been removed]
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.