Re: files & handlers...

From: Stefan Monnier (monnier+lists/caml/news/@tequila.cs.yale.edu)
Date: Mon Feb 07 2000 - 16:23:45 MET

  • Next message: Pierre Weis: "CamlImages library"

    >>>>> "Benoit" == Benoit de Boursetty <debourse@email.enst.fr> writes:
    > And if you write this:
    > let f = open_in filename in input_line f;;
    > (which is more natural to me)
    > you can never close the file you've opened.

    > What would the language have to support in order that opened files be
    > automatically closed when they get out of reach from the program? Is it
    > what is called "finalization"?

    Yes, but it should be avoided if possible because of several
    restrictions in its semantics. For most uses a construct such as

            with_file <name>
              (fn f => <body>)

    will work just as well but with the guarantee that the file will be
    closed at a well specified time.

            Stefan "obviously not familiar enough with Caml's syntax"



    This archive was generated by hypermail 2b29 : Mon Feb 07 2000 - 19:46:50 MET