Browse thread
[Caml-list] assertions or exceptions?
[
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: | Aleksey Nogin <nogin@c...> |
| Subject: | Re: [Caml-list] assertions or exceptions? |
On 15.07.2004 06:58, Radu Grigore wrote: >>let valid_hostname r = >> try ignore (Request.hostname r); true with Not_found -> false > > > Maybe Request.hostname is a bad example. In general you can provide a > query that is more efficient than actually trying to do it. The > example to which I linked in the previous email was about an OpenFile > method that can throw FileNotFound paired with FileExists that returns > a boolean. I'd bet FileExists is not implemented in terms of OpenFile. Actually your FileExists/OpenFile case is a perfect example of why you need exceptions anyway - even if you test a file with FileExists, by the time you invoke OpenFile, the file might be already gone! So unless you want to open yourself to race conditions, the only safe way is to go ahead and use OpenFile, catching any exceptions it could raise. -- Aleksey Nogin Home Page: http://nogin.org/ E-Mail: nogin@cs.caltech.edu (office), aleksey@nogin.org (personal) Office: Jorgensen 70, tel: (626) 395-2907 ------------------- 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