Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-26 Thread Dario Teixeira
Hi, > What experience does people have to using alternatives to exceptions, > such as option types or exception monads? Does use of third part > libraries that still throws exceptions make such approaches hard to use? > Performance wise it seems to be comparable to catching exceptions or > matchin

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-26 Thread Hans Ole Rafaelsen
On Wed, May 26, 2010 at 7:30 PM, Dario Teixeira wrote: > Hi, > > > What experience does people have to using alternatives to exceptions, > > such as option types or exception monads? Does use of third part > > libraries that still throws exceptions make such approaches hard to use? > > Performance

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-26 Thread Jacques Le Normand
Jane Street's Core seems to prefer options to exceptions On Wed, May 26, 2010 at 5:10 PM, Hans Ole Rafaelsen wrote: > > > On Wed, May 26, 2010 at 7:30 PM, Dario Teixeira > wrote: > >> Hi, >> >> > What experience does people have to using alternatives to exceptions, >> > such as option types or e

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-27 Thread Florent Ouchet
Hello, Same here, specially to avoid the Not_found exception. The optional return values gives the oportunity to have a clear view of what is being done if the result is not available. - Florent Jacques Le Normand a écrit : Jane Street's Core seems to prefer options to exceptions On Wed, Ma

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-27 Thread Eray Ozkural
On Thu, May 27, 2010 at 11:08 AM, Florent Ouchet wrote: > Hello, > > Same here, specially to avoid the Not_found exception. > The optional return values gives the oportunity to have a clear view of what > is being done if the result is not available. That depends on the code, I think. In some cas

RE: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-27 Thread David Allsopp
Florent Ouchet wrote: > Same here, specially to avoid the Not_found exception. > The optional return values gives the oportunity to have a clear view of > what is being done if the result is not available. Agreed - though [find] is one of the examples where you do need find and find_exc - because

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-27 Thread Mark Shinwell
On Thu, May 27, 2010 at 09:54:29AM +0100, David Allsopp wrote: > Florent Ouchet wrote: > > Same here, specially to avoid the Not_found exception. > > The optional return values gives the oportunity to have a clear view of > > what is being done if the result is not available. > > Agreed - though [

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-27 Thread Daniel Bünzli
> Agreed - though [find] is one of the examples where you do need find and > find_exc - because often there are occasions where before calling > {Map,Set,Hashtbl}.find you already know that the key exists and so won't > fail at which point the 'a option boxing is a waste of time and space and > Not

RE: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-27 Thread David Allsopp
Daniel Bünzli wrote: > > Agreed - though [find] is one of the examples where you do need find > > and find_exc - because often there are occasions where before calling > > {Map,Set,Hashtbl}.find you already know that the key exists and so > > won't fail at which point the 'a option boxing is a wast

RE: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-27 Thread David Allsopp
Mark Shinwell wrote: > On Thu, May 27, 2010 at 09:54:29AM +0100, David Allsopp wrote: > > Florent Ouchet wrote: > > > Same here, specially to avoid the Not_found exception. > > > The optional return values gives the oportunity to have a clear view > > > of what is being done if the result is not av

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-27 Thread David Rajchenbach-Teller
Hi, If you're interested, three of us on this mailing-list wrote a paper on the topic two few years ago [1]. Best regards, David [1] _Catch me if you can Looking for type-safe, hierarchical, lightweight, polymorphic and efficient error management in OCaml_, http://en.scientificcommons.org

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-27 Thread Alain Frisch
On 05/26/2010 06:15 PM, Hans Ole Rafaelsen wrote: What experience does people have to using alternatives to exceptions, such as option types or exception monads? Does use of third part libraries that still throws exceptions make such approaches hard to use? Performance wise it seems to be compara

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-27 Thread Florent Ouchet
In VSYML [1], the exception Not_found was raised deep in the code in some functions from List and in some redefined functions (such as ocamlutils_find_assoc with a custom key comparer). This project can be assimilable to a code compiler or a code interpreter where these functions are called d

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-27 Thread Hezekiah M. Carty
On Wed, May 26, 2010 at 11:37 PM, Jacques Le Normand wrote: > Jane Street's Core seems to prefer options to exceptions > Batteries also includes a number of Exceptionless modules (ex. Array.Exceptionless) which wrap exception-raising functions to use options instead.

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-27 Thread Richard Jones
On Wed, May 26, 2010 at 06:15:05PM +0200, Hans Ole Rafaelsen wrote: > What experience does people have to using alternatives to exceptions, such > as option types or exception monads? Does use of third part libraries that > still throws exceptions make such approaches hard to use? Performance wise

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-27 Thread Dario Teixeira
Hi, > Personally I've found that you should only throw those exceptions > which can be caught in a single place in the program.  By this I mean > that an exception such as Not_found shouldn't be thrown, and instead > it would be better to use an option type (for stdlib functions which > throw Not_

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-31 Thread Goswin von Brederlow
Richard Jones writes: > On Wed, May 26, 2010 at 06:15:05PM +0200, Hans Ole Rafaelsen wrote: >> What experience does people have to using alternatives to exceptions, such >> as option types or exception monads? Does use of third part libraries that >> still throws exceptions make such approaches h

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-31 Thread Florent Ouchet
Goswin von Brederlow a écrit : Imho a good module should provide both an exception and option based interface to fit the circumstances and programming style. +1 It would be nice if the possible exceptions of a function would be part of the type. E.g. let f1 () = raise Not_found val f1 : u

RE: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-31 Thread David Allsopp
Goswin von Brederlow wrote: > > However if the exception is, say, an I/O error reading a disk file, > > these should be thrown, and caught somewhere central where you can > > display an error message to the user (for GUI programs) or abort the > > current transaction (for server programs). Recove

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-31 Thread Nicolas Pouillard
On Mon, 31 May 2010 16:36:22 +0200, Goswin von Brederlow wrote: > Richard Jones writes: > > > On Wed, May 26, 2010 at 06:15:05PM +0200, Hans Ole Rafaelsen wrote: > >> What experience does people have to using alternatives to exceptions, such > >> as option types or exception monads? Does use of

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-31 Thread Christophe Raffalli
> It would be nice if the possible exceptions of a function would be part > of the type. E.g. > > let f1 () = raise Not_found > val f1 : unit -> 'a [ Not_found ] > > let f2 () = try f1 () with Not_found -> () > val f2 : unit -> unit > > let f3 f = try f () with Not_found -> () > val f3: (unit -> '

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-31 Thread Török Edwin
On 05/31/2010 08:24 PM, David Allsopp wrote: > Goswin von Brederlow wrote: > >>> However if the exception is, say, an I/O error reading a disk file, >>> these should be thrown, and caught somewhere central where you can >>> display an error message to the user (for GUI programs) or abort the >>> c

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-31 Thread Lukasz Stafiniak
On Mon, May 31, 2010 at 9:30 PM, Nicolas Pouillard wrote: > > Since having all functions in all flavours can lead to hard to interface > bloat, one should consider tiny functions to switch from a style to another. > It tends to be easier to start from an option type in the case of Not_found > inst

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-05-31 Thread blue storm
> I use a syntax extension that catches "Not_found" and raises a failure > instead, with the source location of the "real" offending call. I do > this mostly because OUnit catches exceptions so backtraces are of no > use. I have encoutered the same problem and resolved it with explicit backtrace h

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-06-01 Thread Peter Ronnquist
Richard Jones wrote: "... All in all, this is not ideal for writing correct programs. Some sort of exception analysis would be most welcome." Doesn't the "catch me if you can" library provide this? Among the listed features are: * case coverage (i.e. the compiler can tell you if you forgot a

Re: [Caml-list] Static exception analysis or alternative to using exceptions

2010-06-08 Thread Goswin von Brederlow
"David Allsopp" writes: > Goswin von Brederlow wrote: > >> > However if the exception is, say, an I/O error reading a disk file, >> > these should be thrown, and caught somewhere central where you can >> > display an error message to the user (for GUI programs) or abort the >> > current transact