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: | Ville-Pertti Keinonen <will@e...> |
| Subject: | Re: [Caml-list] Why do input* and readdir throw End_of_file ... annoying! |
> I'm pretty convinced that having the input* functions and readdir > throw End_of_file when they run out of data is wrong. Instead > 'readdir' (for example) should be prototyped as: > > readdir : dir_handle -> string option > > and the functions should return None when they run out of data. > Either that or alternative forms which don't throw exceptions should > be available. I don't think it's necessarily such a clear requirement, unless you are assuming the interface for some particular language. Since exceptions are reasonably inexpensive in O'Caml, and used for things such as Not_found in basic collection types, using exceptions to indicate the end of some particular set of values seems reasonable, to me. 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. ------------------- 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