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 UAA10510; Fri, 6 Jun 2003 20:03:48 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA10806 for ; Fri, 6 Jun 2003 20:03:46 +0200 (MET DST) Received: from mail.exomi.com (mail.exomi.com [217.169.64.72]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h56I3jT26406 for ; Fri, 6 Jun 2003 20:03:45 +0200 (MET DST) Received: from exomi.com (unknown [10.0.5.5]) by mail.exomi.com (Postfix) with ESMTP id C7B695D03; Fri, 6 Jun 2003 21:03:44 +0300 (EEST) Date: Fri, 6 Jun 2003 21:03:38 +0300 Subject: Re: [Caml-list] Why do input* and readdir throw End_of_file ... annoying! Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: caml-list@inria.fr To: Richard Jones From: Ville-Pertti Keinonen In-Reply-To: <20030606170131.GA2769@redhat.com> Message-Id: <32CAF7EC-9849-11D7-BAD2-000393863F70@exomi.com> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.552) X-Spam: no; 0.00; caml-list:01 readdir:01 permissive:01 match:02 necessarily:02 o'caml:02 string:03 annoying:03 interface:03 types:03 data:03 exceptions:04 reasonably:04 functions:05 seems:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > 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