Re: Goto inside a call statement?
- From: Jan Vorbrüggen <Jan.Vorbrueggen@xxxxxxxxxxxxxxx>
- Date: Tue, 04 Mar 2008 12:44:48 +0100
One of the reasons I don't like the exception handling features of
most other languages is that they don't even mention the possibility
of error locally. That is, if A calls B which then calls C, and an
exception occurs in C there will be no indication in the source
code of B that C's return will be to some handler in A. The
author of B might indeed be unaware that C might raise exceptions
that it doesn't handle itself. This causes hard to find problems
(since A might have a handler for the exception because of
a known possibility of the condition right there in A: the
handler has no notion of how to correctly handle problems
coming from C). I've seen these myself in several Ada codes.
Or, B might have some things it needs to deallocate or files
to close and be deprived of the opportunity because C didn't
return. I've seen that problem many times too.
All these are indicative of an incorrectly designed exception handling system. The only exception handling system that I know intimately - the one designed for VMS - provides exactly for those scenarios in a way that is reasonably easy to use.
And it still doesn't intermix
the code for proper operation of the program with code to
handle rare anomalies, nor does it require statements that
make redundant tests (*ALL* tests of return codes are redundant,
the procedure that returned them has already decided whether
the exception has arisen or not).
In this connection, making an exception handling facility available at all has significant performance implications on modern processors, which return codes do not have. Finding the proper balance is not easy. Do you want to pay for this, for instance, on every math library call, or would you rather handle it using NANs when and where required?
Note: most of the objections still seem to be coming from people
who regard exception handling as something that allows them
to "clean-up" before terminating. That should actually be a separate
feature (i.e. how should the program respond to a terminate signal?).
Exceptions should be used only for two purposes: 1) to correct
the problem so the program can continue running or 2) to refer the
decision about whether the problem is fatal to some other part
of the program.
Agreed.
Jan
.
- Follow-Ups:
- Re: Goto inside a call statement?
- From: jamesgiles@xxxxxxx
- Re: Goto inside a call statement?
- References:
- Re: Goto inside a call statement?
- From: Sebastian Hanigk
- Re: Goto inside a call statement?
- From: Paul van Delst
- Re: Goto inside a call statement?
- From: James Giles
- Re: Goto inside a call statement?
- Prev by Date: Re: compiling- module - newbie question
- Next by Date: Re: compiling- module - newbie question
- Previous by thread: Re: Goto inside a call statement?
- Next by thread: Re: Goto inside a call statement?
- Index(es):
Relevant Pages
|