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:52)
From: David Teller <David.Teller@u...>
Subject: Re: [Caml-list] [OSR] Exceptionless error management, take 2
On Fri, 2008-02-08 at 00:17 +0900, Jacques Garrigue wrote:
> I have little to say about the approach itself (it may certainly be
> good to know that there are no hidden exceptions.)
> However, the comments at the end look just like copied from Vincent
> Hanquez's mail.
> For me, points 2 and 3 make no sense at all.
> Polymorphic variants allow to check exhaustiveness... as long as you
> use exhaustive pattern matching (i.e. no wildcard, exactly like for
> normal variants.)
> And they _cannot_ pollute any namespace, since they define nothing.
> The other points are subjective.
> Jacques Garrigue

Indeed, they are mostly copied from that mail.

You are correct, the remark about pollution was hasty, I've just removed
it. As for allowing to check exhaustiveness, I grant you that I should
have formulated this differently, but the truth remains that in presence
of wildcards, polymorphic variants allows the very same kind of errors
I'm trying to prevent in this candidate.

For instance, let's consider the following extract:

val parse_int : string -> (int, [`Syntax | `Overflow]) may_fail

match result (parse_int "523.5") with
 | Success i              -> (*...*)
 | Error `IncorrectSyntax -> (*...*)
 | _ as e                 -> throw e

This code is perfectly legitimate. It just happens that it's also false,
because we have used the wrong exception name. It's also the kind of
code which I expect will be quite common: deal with one kind of error
and ignore (or re-raise) the others.

So, while polymorphic variants are quite powerful and quite useful, I
also believe they're the wrong tool for the task.

As for points 1 and 4 are subjective, well, they're open for debate.


David Teller
 Security of Distributed Systems
 Angry researcher: French Universities need reforms, but the LRU act
brings liquidations.