Version française
Home     About     Download     Resources     Contact us    
Browse thread
Wanted: your feedback on the hierarchy of OCaml Batteries Included
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel_Bünzli <daniel.buenzli@e...>
Subject: Re: [Caml-list] Stability of exceptions

Le 21 nov. 08 à 03:56, Eliot Handelman a écrit :

> In order to catch array access violations,

Don't do that. This was already raised on the list but I cannot find  
the reference anymore. One argument that comes to mind is if one day  
you need optimal performance you won't be able to compile with - 
unsafe. Invalid_argument exceptions are programming errors and usually  
you should not try to catch them [1].

> My problem is not confined to this particular case

I agree, the problem also exists with Failure and I already  
encountered it (full Buffer). In that case the safest route is to wrap  
with a handler the greatest body of code that you know can only raise  
Failure because of the particular condition you try to catch and raise  
your own exception on any Failure (see for example the module Buffer  
at the very end of this file [2]).

> Would it not be better for Ocaml to have built-in exceptions (not  
> string literals) for things of this importance?


Of course it would.

Best,

Daniel

[1] http://caml.inria.fr/pub/ml-archives/caml-list/2007/10/e6683fd700e87f214c757ecaaa4f8ede.fr.html
[2] http://erratique.ch/software/xmlm/repo/src/xmlm.ml