comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Assertions (an heretic view)
Date: 1996/06/28
Date: 1996-06-28T00:00:00+00:00	[thread overview]
Message-ID: <DtpqwK.G3D@world.std.com> (raw)
In-Reply-To: gauthier-2806961227410001@164.81.60.62

In article <gauthier-2806961227410001@164.81.60.62>,
Michel Gauthier <gauthier@unilim.fr> wrote:
>IMHO, it is _essential_ to distinguish :
> - _failures_ : some piece of program does not do what it has been designed
>   to do, in an intrinsicly impossible case,
> - _programming errors_ : the programmer did not do what the specification
>   required, including failure cases.

A perfectly reasonable distinction.  However, you cannot, in general,
tell whether it's a "failure" or a "programming error" at the point
where the problem is detected.  This is the whole point of exceptions:
one piece of code can detect the problem, and another piece of code,
possibly far away, can decide whether it is a "failure" or not, and if
so, what to do about it.  (And, of course, the *usual* thing to do with
an exception is to treat it as a programming error, and simply let it
kill the program or go into the debugger or whatever.)

>Underflowing a stack is (almost always) an error, whereas overflowing a
>stack depends on the data and on the environment of each execution, hence
>is a failure.
>
>Failures can _always_ be foreseen, and suitable programming can handle
>them if appropriate, with exceptions or with any other means.
>
>Errors can _never_ be foreseen.
>
>Coming back to assertions, I guess that they essentially relate to errors,
>which they can help detecting. It seems to be a good style not to combine
>assertions with failures.

I disagree, for the above reasons.  If you have a stack overflow, it
might be a "failure", and it might make sense to recover from it.  On
the other hand, I might calculate the maximum stack size, so that my
algorithm is guaranteed not to overflow the stack -- in this case, the
only way the stack can overflow is if I have a programming error.  And
the code for Stacks.Push can't tell which is which.  Only the *caller*
of Stacks.Push can know.

>Moreover, I can't agree with the idea that failing an assertion check would 
>always result in raising Assert_Error. Failing an assertion check is an effect
>of some -possibly incompletely identified- programming error. Different 
>possible continuations can be envisaged : raising a well-specified 
>exception associated with the case, doing some appropriate thing
>(tracing,...), raising some user-defined exception, invoking the debugger,
>and possibly others, among which continuing until other failing checks.
>   This choice depends on the current status of the project, on the
>nature of the checked assertion, on reuse or not, etc. In some cases,
>it may depend also on execution options.

Right.  But "raising an exception" covers all these cases.  Any decent
implementation will let you go into the debugger in case of an unhandled
exception, for example.  Anyway, you have no choice -- the language
Standard doesn't define an Enter_Debugger primitive.

- Bob




  parent reply	other threads:[~1996-06-28  0:00 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4p0fdd$4ml@news.atlantic.net>
1996-06-04  0:00 ` next "big" language?? (disagree) Peter Hermann
1996-06-04  0:00   ` The Amorphous Mass
1996-06-04  0:00     ` Peter Hermann
1996-06-04  0:00       ` The Amorphous Mass
1996-06-05  0:00         ` Michael David WINIKOFF
1996-06-07  0:00           ` Robert Dewar
1996-06-04  0:00     ` Robert Dewar
1996-06-06  0:00       ` Ken Garlington
1996-06-12  0:00       ` Help making ada pretty CSC Trusted Systems Group
1996-06-14  0:00         ` Sandy McPherson
1996-06-19  0:00         ` Ruediger Berlich
1996-06-05  0:00     ` next "big" language?? (disagree) Ian Ward
1996-06-05  0:00       ` The Amorphous Mass
1996-06-08  0:00         ` Robert Dewar
1996-06-08  0:00         ` Robert Dewar
1996-06-08  0:00           ` The Amorphous Mass
1996-06-09  0:00             ` Robert Dewar
1996-06-05  0:00   ` ++           robin
1996-06-05  0:00     ` Ian Ward
1996-06-05  0:00       ` Ian Ward
1996-06-06  0:00         ` Richard Riehle
1996-06-07  0:00           ` Richard Riehle
1996-06-08  0:00             ` O'Connor
1996-06-07  0:00           ` Robert Dewar
1996-06-10  0:00             ` Richard Riehle
1996-06-11  0:00           ` ++           robin
1996-06-11  0:00             ` Chris Warack <sys mgr>
1996-06-11  0:00             ` David Weller
1996-06-11  0:00             ` James_Rogers
1996-06-11  0:00               ` Kevin J. Weise
1996-06-11  0:00         ` ++           robin
1996-06-11  0:00           ` Ian Ward
1996-06-12  0:00             ` ++           robin
1996-06-12  0:00               ` Ian Ward
1996-06-11  0:00       ` Jon S Anthony
     [not found]   ` <4p60nk$imd@euas20.eua.ericsson.se>
     [not found]     ` <4p8lmq$oq7@goanna.cs.rmit.edu.au>
1996-06-11  0:00       ` ++           robin
1996-06-11  0:00         ` A. Grant
1996-06-12  0:00           ` Robert Dewar
1996-06-17  0:00             ` A. Grant
1996-06-18  0:00               ` Robert Dewar
1996-06-24  0:00                 ` Robert I. Eachus
1996-06-26  0:00                   ` Norman H. Cohen
1996-06-19  0:00             ` Jon S Anthony
1996-06-20  0:00               ` Robert Dewar
1996-06-24  0:00                 ` Dale Stanbrough
1996-06-24  0:00                   ` hopkinc
1996-06-24  0:00                   ` Lars Duening
1996-06-24  0:00                   ` Assertions (was: Re: next "big" language?? (disagree)) Robert A Duff
1996-06-24  0:00                     ` Assertions (a different intent?) Gary McKee
1996-06-24  0:00                     ` Assertions (was: Re: next "big" language?? (disagree)) Robert Dewar
1996-06-25  0:00                       ` Robert A Duff
1996-06-28  0:00                         ` Robert Dewar
     [not found]                     ` <4qrljg$15l8@watnews1.watson.ibm.com>
1996-06-28  0:00                       ` Robert Dewar
1996-06-24  0:00                   ` next "big" language?? (disagree) Adam Beneschan
1996-06-24  0:00                   ` Robert Dewar
1996-06-26  0:00                   ` Marc C. Brooks
1996-06-26  0:00                   ` Marc C. Brooks
     [not found]                   ` <4qsbm7$r1s@Starbase.NeoSoft.COM>
1996-06-28  0:00                     ` "Assert"? "Assume"? (was: next "big" language?? (disagree)) Alexander Bunkenburg
1996-06-28  0:00                       ` Ian Collier
1996-07-01  0:00                     ` Cameron Laird
1996-06-24  0:00                 ` next "big" language?? (disagree) Keith Thompson
1996-06-25  0:00                   ` Robert A Duff
1996-06-25  0:00                   ` Simon Read
1996-06-24  0:00                 ` Adam Beneschan
1996-06-25  0:00                 ` Darin Johnson
1996-06-26  0:00                   ` Dale Stanbrough
1996-06-26  0:00                   ` A. Grant
1996-06-25  0:00                 ` Brian Nettleton @pulsar
1996-06-26  0:00                   ` Robert Dewar
1996-06-28  0:00                     ` Fergus Henderson
1996-06-28  0:00                       ` Robert Dewar
1996-06-30  0:00                         ` Fergus Henderson
1996-06-30  0:00                           ` Robert Dewar
1996-06-12  0:00           ` ++           robin
1996-06-12  0:00             ` A. Grant
1996-06-14  0:00               ` Richard A. O'Keefe
1996-06-12  0:00         ` Richard A. O'Keefe
1996-06-12  0:00           ` ++           robin
1996-06-12  0:00             ` Richard A. O'Keefe
1996-06-13  0:00               ` ++           robin
1996-06-13  0:00               ` ++           robin
1996-06-12  0:00   ` Jon S Anthony
1996-06-14  0:00   ` Jon S Anthony
1996-06-15  0:00   ` Jon S Anthony
1996-06-18  0:00     ` Adam Beneschan
1996-06-18  0:00   ` Jon S Anthony
1996-06-28  0:00     ` Assertions (an heretic view) Michel Gauthier
1996-06-28  0:00       ` Robert Dewar
1996-06-28  0:00       ` Robert A Duff [this message]
1996-06-06  0:00 ` next "big" language?? (disagree) Dale Pontius
1996-06-11  0:00 ` Jon S Anthony
1996-06-12  0:00 ` Help making ada pretty Pedro de las Heras
1996-06-18  0:00 ` next "big" language?? (disagree) ++           robin
replies disabled

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