From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA07046; Thu, 12 Dec 2002 15:16:07 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA07044 for ; Thu, 12 Dec 2002 15:16:06 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gBCEG4X13491; Thu, 12 Dec 2002 15:16:04 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA06908; Thu, 12 Dec 2002 15:16:04 +0100 (MET) Date: Thu, 12 Dec 2002 15:16:04 +0100 From: Xavier Leroy To: Dmitry Bely Cc: caml-list@inria.fr Subject: Re: [Caml-list] Resource acquisition is initialization Message-ID: <20021212151604.C3770@pauillac.inria.fr> References: <3DF78FB5.A1642B8@orcaware.com> <20021212141506.A24877@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from dbely@mail.ru on Thu, Dec 12, 2002 at 05:05:42PM +0300 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Maybe I don't understand something but IMHO it's not very usable because > with_file_in type is fixed after the first use. So e.g. input_line and > input_char operation cannot be mixed. You cannot write something like > > let process filename = > let f = with_file_in filename in > begin > print_string (f input_line); > print_char (f input_char); (* syntax error! *) > end Even without the typing problem, this would open and close the file twice, which isn't what you want. The correct usage is: let process filename = with_file_in filename (fun ic -> print_string (input_line ic); print_char (input_char ic)) - Xavier Leroy ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners