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 LAA15882; Mon, 9 Jun 2003 11:33:42 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 LAA15756 for ; Mon, 9 Jun 2003 11:33:41 +0200 (MET DST) Received: from tyminouch.dyndns.org (pc4-cmbg2-5-cust143.cmbg.cable.ntl.com [81.100.86.143]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h599XeT16136 for ; Mon, 9 Jun 2003 11:33:40 +0200 (MET DST) Received: from tyminouch.dyndns.org (tyminouch [127.0.0.1]) by tyminouch.dyndns.org (8.12.5/8.12.5) with ESMTP id h599VAit010122; Mon, 9 Jun 2003 11:31:10 +0200 Received: (from lefessan@localhost) by tyminouch.dyndns.org (8.12.5/8.12.5/Submit) id h599VAXw010119; Mon, 9 Jun 2003 11:31:10 +0200 From: Fabrice Le Fessant MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16100.21470.475977.541047@tyminouch.dyndns.org> Date: Mon, 9 Jun 2003 11:31:10 +0200 To: "Eric C. Cooper" Cc: caml-list@inria.fr Subject: Re: [Caml-list] Why do input* and readdir throw End_of_file ... annoying! References: <20030606170131.GA2769@redhat.com> <32CAF7EC-9849-11D7-BAD2-000393863F70@exomi.com> <20030606184304.GA3396@redhat.com> <20030607150854.GA20233@ecooper.com> X-Mailer: VM 7.14 under Emacs 21.2.1 X-Spam: no; 0.00; caml-list:01 readdir:01 opendir:01 simpler:01 06,:02 match:02 external:03 wrote:03 annoying:03 recursive:03 elegant:04 let:04 fabrice:04 functions:05 fessant:06 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > On Fri, Jun 06, 2003 at 07:43:04PM +0100, Richard Jones wrote: > > The problem is that there doesn't seem to be a way to write the > > loop function using readdir. eg: Why don't you use the while ... do ... done loop instead with an external reference ? let list = ref [] in let dir = opendir "......." in try while true do match readdir dir with "." | ".." -> () | filename -> list := filename :: !list done with End_of_file -> !list Recursive functions are elegant to use, but sometimes, it is simpler to use simple loops instead. - Fabrice ------------------- 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