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
Today's inflamatory opinion: exceptions are bad
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-12-10 (06:29)
From: malc <av1474@c...>
Subject: Re: [Caml-list] Today's inflamatory opinion: exceptions are bad
On Sat, 9 Dec 2006, Brian Hurt wrote:

> I think I've come to the conclusion that exceptions are bad.
> In Ocaml, they're useless in many cases, and in most cases wrong. Avoiding 
> them generally makes for better code.  There are two vague types of 
> exceptions- those the program can, and probably should- handle, and those 
> that the program can't, and probably should even try to, handle.
> For the former, returning a variant type ('a option if nothing else) is a 
> better idea, for (at least) two reasons.  One, the type system enforces the 
> requirement to actually handle the error, at the location the return value of 
> the function is desired.  Want the result?  Handle the errors. Which allow a 
> function to "pass along" an error if it wants to.  So you could still write 
> functions like:


Guess there's third type, code might detect catastrophic failure
during the run of custom block finalizer, in which case, should there
be a need for a cleanup actions, raising an exception might be the
only choice, however i couldn't say offhand whether OCaml allows to
raise exceptions in this context at all.