Browse thread
[Caml-list] Why do input* and readdir throw End_of_file ... annoying!
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | David Brown <caml-list@d...> |
| Subject: | Re: [Caml-list] Why do input* and readdir throw End_of_file ... annoying! |
On Sat, Jun 07, 2003 at 11:08:54AM -0400, Eric C. Cooper wrote: > and read_directory path = > let dirh = opendir path in > let rec loop entries = > try match readdir dirh with > | "." | ".." -> loop entries > | filename -> loop (read_filesystem filename :: entries) > with End_of_file -> entries > in > let list = loop [] in > closedir dirh; > list But, this isn't tail recursive, so you might as well not pass the argument and build up the list upon returning. Is there a way of making it really tail recursive, while using the exception? It isn't too hard with a list ref to accumulate the results. Dave ------------------- 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