Browse thread
[OSR] Exceptionless error management
[
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: | Andrej Bauer <Andrej.Bauer@f...> |
| Subject: | Re: [Caml-list] [OSR] Exceptionless error management |
Bünzli Daniel wrote: > let find map k = match Map.find map k with Some v -> v | None -> assert > false I have become to prefer option types as return values (as opposed to exceptions), but I admit it can be annoying to always consider both possibilities, especially if you know that "None" won't happen. If the library only provides "find" that returns an option type, the above solution gets around constant checking. But how much runtime overhead does it cause? Has anyone measured that? What is wrong with having two functions? With a bit of imagination, we can give them reasonable names, e.g., get and search. Everybody can guess which one returns the option type and which one throws an exception, right? Throwing out functionality on the grounds that it "clutters APIs" doesn't sound like a good idea to me. Throwing out bells and whistles is another matter. Andrej