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: | Jon Harrop <jon@f...> |
| Subject: | Re: [Caml-list] [OSR] Exceptionless error management |
On Thursday 31 January 2008 20:25:41 David Teller wrote: > 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 ? Scrap the explicitly-declared sum type for a polymorphic variant, lazy value for a function and catch only a specific exception and you've got the approach that I already use. You can factor this out but this is so rarely used that it isn't worth it. If the stdlib had common IO functions I wouldn't use that idiom at all. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e