From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA08275 for caml-redistribution@pauillac.inria.fr; Mon, 7 Feb 2000 19:43:13 +0100 (MET) Resent-Message-Id: <200002071843.TAA08275@pauillac.inria.fr> Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA02932 for ; Mon, 7 Feb 2000 16:24:10 +0100 (MET) Received: from tequila.cs.yale.edu (tequila.cs.yale.edu [128.36.229.152]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id QAA18335 for ; Mon, 7 Feb 2000 16:24:00 +0100 (MET) Received: from tequila.cs.yale.edu (localhost [127.0.0.1]) by tequila.cs.yale.edu (8.9.3/8.9.3) with SMTP id KAA23570 for ; Mon, 7 Feb 2000 10:23:50 -0500 To: caml-list@inria.fr Sender: monnier@rum.cs.yale.edu From: "Stefan Monnier" Newsgroups: lists.caml Subject: Re: files & handlers... References: Date: 07 Feb 2000 10:23:45 -0500 Message-ID: <5lu2jlghoe.fsf@rum.cs.yale.edu> X-Newsreader: Gnus v5.7/Emacs 21.0 Path: rum.cs.yale.edu NNTP-Posting-Host: rum.cs.yale.edu X-Trace: 7 Feb 2000 10:23:45 -0500, rum.cs.yale.edu Resent-From: weis@pauillac.inria.fr Resent-Date: Mon, 7 Feb 2000 19:43:13 +0100 Resent-To: caml-redistribution@pauillac.inria.fr >>>>> "Benoit" == Benoit de Boursetty 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 (fn f => ) 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"