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 UAA11824; Fri, 6 Jun 2003 20:43:06 +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 UAA11722 for ; Fri, 6 Jun 2003 20:43:05 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h56Ih4H00943 for ; Fri, 6 Jun 2003 20:43:04 +0200 (MET DST) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 19OMB6-0000tr-00 for ; Fri, 06 Jun 2003 19:43:04 +0100 Date: Fri, 6 Jun 2003 19:43:04 +0100 Cc: caml-list@inria.fr Subject: Re: [Caml-list] Why do input* and readdir throw End_of_file ... annoying! Message-ID: <20030606184304.GA3396@redhat.com> References: <20030606170131.GA2769@redhat.com> <32CAF7EC-9849-11D7-BAD2-000393863F70@exomi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <32CAF7EC-9849-11D7-BAD2-000393863F70@exomi.com> User-Agent: Mutt/1.5.4i From: Richard Jones X-Spam: no; 0.00; caml-list:01 readdir:01 permissive:01 pathname:01 freshmeat:01 vectors:01 hashes:01 funcs:01 allocator:01 ltd:98 rec:01 lib:01 06,:02 london:97 match:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, Jun 06, 2003 at 09:03:38PM +0300, Ville-Pertti Keinonen wrote: > Writing a try ... with statement isn't really that different from a > match statement except for the fact that you can handle exceptional > circumstances generated by several expressions in the with ... part of > a try ... with statement - if anything, that's more permissive. The problem is that there doesn't seem to be a way to write the loop function using readdir. eg: let rec loop () = let filename = readdir dirh in match filename with | "." -> loop () | ".." -> loop () | filename -> let pathname = path ^ "/" ^ filename in let stat = lstat pathname in let this = if stat.st_kind = S_DIR then read_directory pathname else File pathname in this :: loop () in try Directory (loop ()) with End_of_file -> XXX what? Because the exception is always raised (it's not an exception at all) there's no way to return the result of the call to loop (). Rich. -- Richard Jones, Red Hat Inc. (London) and Merjis Ltd. http://www.merjis.com/ http://www.annexia.org/ Freshmeat projects: http://freshmeat.net/users/rwmj C2LIB is a library of basic Perl/STL-like types for C. Vectors, hashes, trees, string funcs, pool allocator: http://www.annexia.org/freeware/c2lib/ ------------------- 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