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 TAA17356; Fri, 27 Sep 2002 19:06:31 +0200 (MET DST) 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 TAA17390 for ; Fri, 27 Sep 2002 19:06:30 +0200 (MET DST) Received: from mlabdial.hit.bme.hu (mlabdial.hit.bme.hu [152.66.248.201]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g8RH6T500567; Fri, 27 Sep 2002 19:06:29 +0200 (MET DST) Received: from localhost (kgergely@localhost) by mlabdial.hit.bme.hu (8.11.6/8.11.6) with ESMTP id g8RH6SR00400; Fri, 27 Sep 2002 19:06:28 +0200 Date: Fri, 27 Sep 2002 19:06:28 +0200 (CEST) From: "Kontra, Gergely" To: Maxence Guesdon cc: Florian Hars , caml-list@inria.fr Subject: Re: [Caml-list] (Sorry for my last post) lazyness, exceptions?, ocaml syntax rule-of-thumbs In-Reply-To: <20020927170755.142d6390.maxence.guesdon@inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >> > One point was ocaml is really obscure is the file reading: it needed to >> > wrap the line-reading in an infinite loop, and this loop is ended via an >> > exception. I think End_of_file is not an exception, it is just an event. > >What next ? int_of_string "foo" returning None ? No, that wouldn't be a good idea. But writing int_of_string "foo" is a bad thing, while the end-of-file thing is not a design problem. Is there a function to test eof? (without consuming a line?) >If you want to read a whole file as a string, you can use the >following function: [snip] Well, but what about memory usage? I just miss an iterator, or sg. like that, which reads a line, processes it, reads next line... Just want to write cleaner, which eg. in ruby is just (so intuitive) IO.foreach("filename.ext") {|line| # process line } and don't like infinite loops. Gergo +-[Kontra, Gergely @ Budapest University of Technology and Economics]-+ | Email: kgergely@mcl.hu, kgergely@turul.eet.bme.hu | | URL: turul.eet.bme.hu/~kgergely Mobile: (+36 20) 356 9656 | +-------"Olyan langesz vagyok, hogy poroltoval kellene jarnom!"-------+ . Magyar php mirror es magyar php dokumentacio: http://hu.php.net ------------------- 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