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, take 2
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-02-07 (15:37)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] [OSR] Exceptionless error management, take 2
On Thursday 07 February 2008 15:01:22 David Teller wrote:
>  As it seems that the first take on exceptionless error management has
> been discarded, I have put together a second candidate. This proposal
> takes into account the discussions from the first candidate, should
> resolve the issues introduced by that first candidate -- and presumably
> open a few other cans of worms somewhere along the way.

There is also some merit in the hierarchical classification of exceptions, 
e.g. as .NET provides (class hierarchies). For example, you might make 
Invalid_argument a base exception with derived exceptions for each of the 
different functions that raise this exception, in order to carry more precise 
information about what exactly went wrong. OCaml's current approach of 
conveying a string argument is not in the API and feels unhygienic as a 
consequence. Like brushing your teeth whilst on the toilet. We all do it, but 
only because we're in a hurry and not because it is an inherently good idea.

Anyway, this can be achieved using variant and polymorphic variant exception 
arguments in OCaml. However, as Zheng Li pointed out late last year, OCaml is 
broken with respect to polymorphic variant exception arguments, e.g. this 

  exception E of [>];; 
  try raise(E`X) with E`X x-> !x

I don't know where the boundary in the language lies, beyond which it is 
unsafe/wrong, so I think it would be constructive to describe this and 
your "exception+polymorphic variant"-related proposal seems like a good place 
to do so.

Just an idea...

Dr Jon D Harrop, Flying Frog Consultancy Ltd.