Browse thread
[OSR] Exceptionless error management
-
Bünzli_Daniel
- David Teller
- David Teller
- David Teller
- Till Varoquaux
[
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: | Till Varoquaux <till.varoquaux@g...> |
| Subject: | Re: [Caml-list] [OSR] Exceptionless error management |
My cocan account is not created yet soo I will answer here: _ In the thread you are pointing to Xavier did not say using exceptions was a mistake, he said the Failure exception (such as int_of_string) was legacy code and not great. _ Allowing Invalid_argument seems a little to hardcore. When doing system programming for instance there is an incredible range of exceptional events that can happen, you are definitly not going to handle all of them (or are you?) so you will need to let them trickle up. This will eventually require using something akin to an error monad and some awfull mangling with polymorpic variants. _Exceptions are terse. Suppose Map.find returned an option type (and this seems a sensible choice). If you were in a place where not being in the map really was an exceptional event you'd need to unbox and do some error handling for every lookup (and since you do not want to raise an exception I must wonder what you would do). Not only is this cumbersome, but it also is bound to be slow and lead to some loss of information (no more printexc, backtrace...) unless you jump through a lot of hoops. Here is my take: _You should try to keep exceptions for exceptional cases. If you think you might need to catch them do not hesitate to create your own exception. _For functions like find... declare two functions: one that boxes it's return value (i.e val input_line : in_channel -> string option) and another that raises an exception (i.e val input_line_exn : in_channel -> string). Till On Jan 31, 2008 8:55 AM, Bünzli Daniel <daniel.buenzli@erratique.ch> wrote: > Hello, > > Based on discussions and the resulting consensus that occured more > than once on this list. I wrote a recommendation on how modules should > perform error management. It is available here : > > http://cocan.org/osr/exceptionless_error_management > > Best, > > Daniel > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > -- http://till-varoquaux.blogspot.com/