comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Problems with SPARK 2015 and XMLAda
Date: Thu, 20 Aug 2015 12:13:47 -0700
Date: 2015-08-20T12:13:47-07:00	[thread overview]
Message-ID: <mr58q4$7nv$1@dont-email.me> (raw)
In-Reply-To: <alpine.CYG.2.11.1508201440030.7892@WIL414CHAPIN.vtc.vsc.edu>

On 08/20/2015 11:42 AM, Peter Chapin wrote:
> 
> To clarify, SPARK 2014 does allow raise statements in programs. However, each
> Raise statement carries with it a proof obligation that it will never execute.
> What's the point of that? It allows you to use raise statements to document
> "impossible" situations and then have the tools attempt to prove that those
> situations are, indeed, impossible.

SPARK is usually discussed in the context of complete programs, in which you
prove both that a subprogram is correct if the caller meets the precondition,
and that all calls meet the precondition.

However, in the case of a library unit that may be called by multiple programs,
it may be desirable to be able to prove the correctness of the unit without
being able to prove that all calls will be correct. In such cases, having
assertion checking catch the precondition violation and raise an exception is
the best solution should the unit be misused.

Also, some preconditions are very expensive to check; consider the "N is prime"
example discussed here in another thread. In such a case, it may be that the
normal processing allows detecting a precondition violation much more cheaply
than checking the precondition at the time of the call. In that case, a
conditional raise statement, which the condition being provably false if the
precondition is met. Then the unit can be proven correct if the precondition is
met, execute without the expensive precondition check in the case where the call
is not proven correct, and still raise an exception if it is called with the
precondition not met.

So it does seem there are cases where this feature may be useful.

-- 
Jeff Carter
"I've seen projects fail miserably for blindly
applying the Agile catechism: we're Agile, we
don't need to stop and think, we just go ahead
and code!"
Bertrand Meyer
150

  reply	other threads:[~2015-08-20 19:13 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-19 15:58 Problems with SPARK 2015 and XMLAda Serge Robyns
2015-08-19 20:21 ` Simon Wright
2015-08-19 21:22   ` Serge Robyns
2015-08-20  7:10     ` Jacob Sparre Andersen
2015-08-20 10:06       ` Mark Lorenzen
2015-08-20 16:38     ` Shark8
2015-08-20 18:42       ` Peter Chapin
2015-08-20 19:13         ` Jeffrey R. Carter [this message]
2015-08-20 20:00       ` Serge Robyns
2015-08-20 20:36       ` Randy Brukardt
2015-08-20 23:21         ` Shark8
2015-08-21  6:26         ` Stefan.Lucks
2015-08-21  7:30           ` Dmitry A. Kazakov
2015-08-21  8:19             ` Stefan.Lucks
2015-08-21  9:37               ` Dmitry A. Kazakov
2015-08-21 10:09                 ` G.B.
2015-08-21 11:56                   ` Dmitry A. Kazakov
2015-08-21 13:46                     ` G.B.
2015-08-21 14:45                       ` brbarkstrom
2015-08-21 15:34                       ` Dmitry A. Kazakov
2015-08-21 23:44                       ` Bob Duff
2015-08-22  6:22                         ` Dmitry A. Kazakov
2015-08-21 10:43                 ` Stefan.Lucks
2015-08-21 12:35                   ` Dmitry A. Kazakov
2015-08-24 21:32               ` Randy Brukardt
replies disabled

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