comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Strategies with SPARK which does not support exceptions
Date: Tue, 29 Jun 2010 15:05:50 -0500
Date: 2010-06-29T15:05:50-05:00	[thread overview]
Message-ID: <i0djn0$11a$1@munin.nbi.dk> (raw)
In-Reply-To: d90f60dd-b74f-4eff-b9d8-803ebb64c9d2@z8g2000yqz.googlegroups.com


"Claude" <claude.defour@orange.fr> wrote in message 
news:d90f60dd-b74f-4eff-b9d8-803ebb64c9d2@z8g2000yqz.googlegroups.com...
>
>Exceptions are not the best way to process error. (i.e., Not just a
>SPARK topic).

There is an extra "not" in your statement. :-) You must have meant 
"Exceptions are the best way to process error."

Result codes are dangerous, as ignoring of result codes is one of the major 
problems in programming, and the resulting bugs are very, very hard to find. 
(That's because of the difficulty of finding errors of omission.)

Perhaps you are too young to remember, but early versions of Windows (3.0, 
3.1) had a reputation for being unstable and crashing often. But the 
problems were mostly not with Windows but rather with programs that tended 
to ignore the error returns from the Windows API. As such, they tended to 
continue running but using non-existent Windows handles and the like. Given 
the lack of memory protection on 16-bit computers, these errors tended to 
take the entire Windows subsystem with them.

We developed a "middle-level" binding for programming Windows, which used 
exceptions rather than error codes, and programs developed with it tended to 
be much more stable than the commercial programs we were using at the 
time --- probably because even when they failed, they didn't take the entire 
OS with them (just popped up a message box and terminated properly).

I understand the problems with safety-critical systems and the need to test 
to check exceptions, but I believe that the proper solution to those 
problems is on the line of exception contracts and proving exception absence 
when necessary to fufill those contracts. In particular, if a routine is 
declared to not propagate Constraint_Error, then the routine is incorrect if 
it in fact could propagate that exception. (I'm mildly annoyed that we 
didn't have time in Ada 2012 to pursue those sorts of contracts seriously.)

There is no technical reason that tools like SPARK couldn't support 
exceptions if they wanted to do so. Compiler optimizers are a form of proof 
tool, and they have no problem dealing with exceptions. (That's because the 
control flow caused by exceptions is quite limited, and is generally out of 
blocks -- outbound flow has little effect on proofs within a block).

Returning to the dark ages of programming (that is BE - Before Exceptions) 
and reintroducing all of the problems of early C code just because of 
inadequate tools seems like a horrible step backwards to me.

This is exactly why I'm not much interested in SPARK itself: because it 
forces programs back into the style that I originally learned for Fortran IV 
in 1976: no dynamic allocation, no dynamic calls, no exceptions -- no 
interest! I'm interested in what SPARK brings to the table in proof 
capabilities, but I see no reason to give up 3/4rds of Ada to get it. 
(Remember that Ada allocators, Ada O-O dispatching, Ada access-to-subprogram 
calls, are all type-safe and provide plenty of opportunity for reasoning).

                       Randy Brukardt.





  parent reply	other threads:[~2010-06-29 20:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-17 15:33 Strategies with SPARK which does not support exceptions Yannick Duchêne (Hibou57)
2010-06-17 17:11 ` Warren
2010-06-17 18:19   ` Yannick Duchêne (Hibou57)
2010-06-21 13:31     ` Warren
2010-06-21 14:10       ` Alexandre K
2010-06-17 19:54 ` Pascal Obry
2010-06-17 22:47   ` Peter C. Chapin
2010-06-18  6:07 ` Claude
2010-06-18  8:06 ` Phil Thornley
2010-06-18  8:49   ` Martin
2010-06-18 17:16     ` mockturtle
2010-06-18 21:51       ` Alexandre K
2010-06-22 17:01   ` Phil Clayton
2010-06-22 23:14 ` Claude
2010-06-23 16:22   ` Warren
2010-06-24  3:24     ` Claude
2010-06-28 13:14       ` Warren
2010-06-29  8:39         ` Stephen Leake
2010-06-29 20:05       ` Randy Brukardt [this message]
2010-06-29 20:49         ` Georg Bauhaus
2010-06-30  5:08         ` Simon Wright
2010-06-30  8:17         ` stefan-lucks
replies disabled

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