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 PAA25868; Thu, 15 Jul 2004 15:34:02 +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 PAA26165 for ; Thu, 15 Jul 2004 15:34:01 +0200 (MET DST) Received: from annexia.force9.co.uk (annexia.force9.co.uk [212.56.101.183]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i6FDY0EV031357 for ; Thu, 15 Jul 2004 15:34:00 +0200 Received: from rich by annexia.force9.co.uk with local (Exim 3.36 #1 (Debian)) id 1Bl6N5-0003Tk-00 for ; Thu, 15 Jul 2004 14:33:59 +0100 Date: Thu, 15 Jul 2004 14:33:59 +0100 Cc: caml-list@inria.fr Subject: Re: [Caml-list] assertions or exceptions? Message-ID: <20040715133359.GA13273@redhat.com> References: <7f8e92aa04071501035091cbe9@mail.gmail.com> <20040715101826.GA10062@redhat.com> <7f8e92aa04071505495315454@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7f8e92aa04071505495315454@mail.gmail.com> User-Agent: Mutt/1.5.5.1+cvs20040105i From: Richard Jones X-Miltered: at nez-perce with ID 40F687C8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 advocated:01 troll:01 nonetheless:01 stdlib:01 clunky:01 autoconf:01 automake:01 compiles:01 rpms:01 ltd:98 bool:01 ocaml:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, Jul 15, 2004 at 03:49:19PM +0300, Radu Grigore wrote: > Note that in your example there is always a third choice (the one > advocated by .NET class library design guidelines): do what you do but > also provide a function > > Request.valid_hostname : Request.t -> bool I feel I might be responding to a troll here. It seems to me to be a little obvious that you haven't done much programming OCaml, or else you wouldn't be asking this question. There's an ocaml-beginners list if you'd like to find out more about developing with OCaml. Nevertheless ... let valid_hostname r = try ignore (Request.hostname r); true with Not_found -> false Or, if Request.hostname had been defined the other way, then: let valid_hostname r = match Request.hostname r with None -> false | Some _ -> true In practice you'd never actually write the "valid_hostname" function explicitly, because it's so trivial to inline the code when you need it. > Ok, so I can hide the usage of the exception. It doesn't make me feel > much better. It feels more like redesigning the interface of the > standard library. (but it's a good idea nonetheless). I happen to think that the End_of_file stuff in stdlib *is* quite clunky. However since my main usage of files is "open file; read entire contents into list of lines; close file", or "open file; write this list of lines; close file", and I now have my own functions which do both those operations in a single call, it doesn't bother me much. Rich. -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment MAKE+ is a sane replacement for GNU autoconf/automake. One script compiles, RPMs, pkgs etc. Linux, BSD, Solaris. http://www.annexia.org/freeware/makeplus/ ------------------- 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