Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Today's inflamatory opinion: exceptions are bad
On Sun, Dec 10, 2006 at 06:27:37PM -0500, Chris King wrote:
> On 12/10/06, Richard Jones <rich@annexia.org> wrote:
> >On Sat, Dec 09, 2006 at 10:35:56PM -0500, Chris King wrote:
> >> One thing Java (sort of) gets right is keeping track of which
> >> exceptions a function can throw, making it easy to ensure that some
> >> deeply nested piece of code won't cause the entire application to die
> >> from some obscure exception.  I'd love to see a similar feature in
> >> O'Caml, whereby the exceptions which a function can raise are part of
> >> its type and are inferred and checked by the compiler.
> >
> >Oh please no!  Checked exceptions are the dumbest and most frustrating
> >feature of Java (and that's saying something - the Java language has
> >far more frustrations than most programming languages).

I'll moderate what I said before by adding that I now think there are
some exceptions which should never be ignored - for example, it seems
like it's always a mistake to ignore Not_found or End_of_file.  On the
other hand I would almost always want to ignore Sys_error, or else
catch it far away from its point of origin in a wrapper around the
whole program or an event handler.

Perhaps though this is an argument that List.find and friends should
be returning 'a option, not an argument for all exceptions being bad.

> I fully agree.  Forcing the programmer to acknowledge the presence of
> every possible exception is annoying to write and makes for fragile
> code.  Hence I suggested exception inference... no extra effort is
> required on the part of the programmer and the code is not made
> fragile.  O'Caml provides the safety of checked types without the
> hassle of type declarations; in the same way it could provide the
> safety of checked exceptions without the hassle of exception
> declarations.

Agreed.  I'd like to see a detailed prototype.

Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Internet Marketing and AdWords courses - http://merjis.com/courses - NEW!
Merjis blog - http://blog.merjis.com - NEW!