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
[OSR] Exceptionless error management
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-01-31 (14:09)
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.