Browse thread
[OSR] Exceptionless error management
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | David Teller <David.Teller@u...> |
| Subject: | Re: [Caml-list] [OSR] Exceptionless error management |
On Thu, 2008-01-31 at 21:03 +0100, Bünzli Daniel wrote:
> Le 31 janv. 08 à 15:09, Andrej Bauer a écrit :
>
> > 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.
>
> Maybe it is a point of view, you are fed up of considering both
> possibilites while I'm personally fed up of writing
>
> match try Some (f x) with e -> None with
> | None -> ..
> | Some v -> ...
>
> Because I need tail recursive functions.
What about a generic
type result 'r 'e =
| Success of 'r (**The operation was a success*)
| Failure of 'e (**The operation was a failure*)
let purify e =
try
Success ( Lazy.force e )
with
exc -> Failure exc
?
With one such mechanism we can nearly automatically transform
exception-returning expressions into exceptionless management. We could
complete this with a trivial amount of Camlp4 code to avoid the call to
"lazy / Lazy.force".
What do you think about this solution ?
Cheers,
David
--
David Teller
Security of Distributed Systems
http://www.univ-orleans.fr/lifo/Members/David.Teller
Angry researcher: French Universities need reforms, but the LRU act
brings liquidations.