[m-dev.] checked exceptions.

Julien Fischer jfischer at opturion.com
Thu Feb 14 13:07:37 AEDT 2013


Hi,

On Wed, Feb 13, 2013 at 10:32 AM, Paul Bone <paul at bone.id.au> wrote:

> How do people feel about checked exceptions?

As a programmer, I find that they make coding in Java quite irritating.
There is an interesting discussion with Anders Hejlsberg about why C#
does not have a notion of checked exceptions:
<http://www.artima.com/intv/handcuffs.html>.

> The example I'm most familiar with is Java's implementation.

Name some more examples of languages with checked exceptions.  I think the
lack of this feature in other, particularly mainstream, languages is
rather telling ...

> Some exceptions are unchecked, these include out of memory, divide by zero etc.
> Other exceptions are checked, these include file not found, permissions
> errors, disk full and almost all user defined exceptions.
>
> If your method might throw a checked exception then it must declare the
> possibility of the exception as part of it's signature.  Any method calling
> this method is forced either to catch and handle the exception, or to
> declare that it may be thrown.
>
> This could be useful in Mercury to make it even easier to write reliable
> software.

What is more likely is that good programmers will write reliable software
while the others will get up to the usual Java-style tricks to avoid complier
warnings about not handling checked exceptions.

> We can already force the caller of a predicate to check for
> errors by decomposing a type that our predicate returns.

Only in some circumstances.

...

> I propose we add this feature, its implementation should be straight forward
> (except for syntax discussions).

I'm against adding support for them.

> If a majority aren't willing to support the
> idea then it could be implemented and turned off by default.

Supporting it at all will require introducing a bunch of clutter to
the standard library,
regardless of whether checking is turned on or not - I'm not sure I
want that either.

Cheers,
Julien.



More information about the developers mailing list