Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2003-06-06 (18:03)
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 

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 Archives:
Bug reports: FAQ:
Beginner's list: