comp.lang.ada
 help / color / mirror / Atom feed
From: Joachim Durchholz <joachim.durchholz@munich.netsurf.de>
Subject: Re: Building blocks (Was: Design By Contract)
Date: 1997/09/15
Date: 1997-09-15T00:00:00+00:00	[thread overview]
Message-ID: <341DA755.CA55073C@munich.netsurf.de> (raw)
In-Reply-To: 5v34m5$pl9$1@trumpet.uni-mannheim.de


Marc Wachowitz wrote:
> ...I consider something like Eiffel's class EXCEPTION an ugly
> hack to differentiate between kinds of exceptions.

Indeed it is. Mimicking Java's elaborate I/O exception hierarchy would
be a nightmare.

However, exceptions don't have to serve as many purposes in Eiffel as in
Java.

First of all, Eiffel is designed for side-effect-free functions. A
subroutine is either a command (procedure, function with void return
type) that may change the externally perceivable state of an object. Or
it is a query (function, function with non-void return type) that allows
us to perceive the state of the object.
This means file I/O (to most plentiful source of exceptions I think)
works totally different than in Java or C. There is no getchar()
function, which would change the state of the associated FILE object
*and* return a value. Instead, you can have a get_file_block(from,to)
procedure that tries to read the bytes in the given from..to range; if
an I/O error occurs, the FILE object takes note of the error. Nothing
else is done in get_file_block; however, FILE also offers a set of
queries to determine wether the last access was successful, failure
reasons if not, access to data as far as it could be read, etc. etc.

What remains for exception handling are two sources:
1) Truly unexpected stuff, which is traditionally reported with the
prefix "This can't happen:". There isn't much that can be done about
such events - a human must look at the message and decide what to do -
which EXCEPTION will readily handle.
2) There are a few operations where checking wether they will work
before calling them is as expensive as running the operation. Typical
examples are arithmetic overflow conditions and matrix inversions. In
these cases, the exceptions are raised at the call and should be handled
immediately after the call. Again, the services from EXCEPTION are
sufficient to handle this.

What I think is misdesigned is the retry mechanism - to continue after
an exception, an Eiffel routine *must* restart at its beginning and
successfully run through to the end. Retrying is the right answer in
several cases, in particular if hardware is involved, but there are lots
of other applications, and the retry mechanism makes for some ugly and
needlessly complex control flows. (Which is one of the reasons why
exception processing is done only if necessary, which is exactly a
design goal of Eiffel - maybe the unwieldiness of retry is by design?)

Regards,
Joachim
-- 
Please don't send unsolicited ads.






  reply	other threads:[~1997-09-15  0:00 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-09  0:00 Building blocks (Was: Design By Contract) Marc Wachowitz
1997-09-15  0:00 ` Joachim Durchholz [this message]
1997-09-17  0:00 ` Paul Johnson
1997-09-18  0:00   ` Robert Dewar
1997-09-18  0:00   ` Jon S Anthony
1997-09-18  0:00   ` Stephen Leake
1997-09-18  0:00     ` Mark L. Fussell
1997-09-19  0:00       ` Jon S Anthony
1997-09-23  0:00         ` Mark L. Fussell
1997-09-19  0:00       ` Robert A Duff
1997-09-20  0:00         ` Joachim Durchholz
1997-09-22  0:00           ` Matthew Heaney
1997-09-23  0:00             ` Joachim Durchholz
1997-09-23  0:00             ` Veli-Pekka Nousiainen
1997-10-03  0:00               ` Robert I. Eachus
1997-10-04  0:00                 ` Paul Johnson
1997-10-14  0:00                   ` Robert I. Eachus
1997-09-23  0:00           ` Jon S Anthony
1997-09-24  0:00           ` Alan E & Carmel J Brain
1997-09-25  0:00             ` Anonymous
1997-09-30  0:00               ` Alan E & Carmel J Brain
1997-09-30  0:00                 ` Matthew Heaney
1997-09-30  0:00                   ` W. Wesley Groleau x4923
1997-09-30  0:00                     ` Matthew Heaney
1997-10-01  0:00                     ` Alan E & Carmel J Brain
1997-09-30  0:00                   ` Neil Wilson
1997-09-30  0:00                     ` Stephen Leake
1997-10-01  0:00                 ` Anonymous
1997-10-01  0:00                   ` Joachim Durchholz
1997-10-01  0:00                   ` Paul M Gover
1997-10-04  0:00                     ` Paul Johnson
1997-10-04  0:00                       ` Matthew Heaney
1997-10-15  0:00                         ` Paul Johnson
1997-10-15  0:00                           ` Matthew Heaney
1997-10-16  0:00                             ` Joachim Durchholz
1997-10-17  0:00                               ` Robert I. Eachus
1997-10-16  0:00                           ` Joachim Durchholz
1997-10-22  0:00                           ` Reimer Behrends
1997-10-02  0:00                   ` Robert A Duff
1997-10-02  0:00                     ` Tucker Taft
1997-10-02  0:00                       ` Matthew Heaney
1997-10-03  0:00                     ` Stephen Leake
1997-10-04  0:00                     ` Matthew Heaney
1997-10-07  0:00                       ` Robert A Duff
1997-09-24  0:00           ` Richard A. O'Keefe
     [not found]       ` <11861963wnr@eiffel.demon.co.uk>
1997-09-19  0:00         ` Mark L. Fussell
1997-09-18  0:00     ` W. Wesley Groleau x4923
1997-09-21  0:00       ` Matthew Heaney
  -- strict thread matches above, loose matches on Subject: below --
1997-09-11  0:00 Robert Dewar
1997-09-09  0:00 Marc Wachowitz
1997-09-02  0:00 Design By Contract Jon S Anthony
     [not found] ` <JSA.97Sep3201329@alexandria.organon.com>
1997-09-04  0:00   ` Paul Johnson
     [not found]     ` <5un58u$9ih$1@gonzo.sun3.iaf.nl>
1997-09-06  0:00       ` Building blocks (Was: Design By Contract) Joachim Durchholz
1997-09-08  0:00       ` Paul Johnson
1997-09-08  0:00         ` Brian Rogoff
1997-09-09  0:00           ` Veli-Pekka Nousiainen
1997-09-09  0:00           ` Veli-Pekka Nousiainen
1997-09-09  0:00             ` Jon S Anthony
1997-09-09  0:00           ` W. Wesley Groleau x4923
1997-09-09  0:00           ` Matthew Heaney
1997-09-09  0:00             ` Brian Rogoff
1997-09-09  0:00             ` W. Wesley Groleau x4923
1997-09-10  0:00               ` Robert A Duff
1997-09-12  0:00                 ` Jon S Anthony
1997-09-10  0:00             ` Robert Dewar
1997-09-12  0:00               ` Jon S Anthony
1997-09-12  0:00                 ` Robert Dewar
1997-09-16  0:00                   ` Brian Rogoff
1997-09-12  0:00               ` Paul Johnson
1997-09-14  0:00                 ` Robert Dewar
1997-09-14  0:00                 ` Robert Dewar
1997-09-15  0:00                   ` John G. Volan
1997-09-14  0:00                 ` Robert Dewar
1997-09-10  0:00             ` Paul Johnson
1997-09-10  0:00               ` Darren New
1997-09-10  0:00               ` Matthew Heaney
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox