English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Why do input* and readdir throw End_of_file ... annoying!
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Why do input* and readdir throw End_of_file ... annoying!
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
	  File pathname in
	this :: loop ()
    Directory (loop ())
    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 ().


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