comp.lang.ada
 help / color / mirror / Atom feed
From: Peter Amey <peter.amey@praxis-cs.co.uk>
Subject: Re: Ada and Design By Contract
Date: Tue, 25 Mar 2003 08:25:29 +0000
Date: 2003-03-25T08:25:29+00:00	[thread overview]
Message-ID: <3E801279.80905@praxis-cs.co.uk> (raw)
In-Reply-To: d37844cb.0303240940.13be700e@posting.google.com



Volkert wrote:
[snip]
> 
>>The big problem here is that the really interesting 
>>contractual claims may involve items not visible at the point where the 
>>contract is being checked (unless the code is rewritten with reduced 
>>abstraction to make them visible).
> 
> I see not the problem. Can you give a short example.
> 
> Volkert

A small (but probably not the best) example:

package P is
   function IsFull return Boolean;
   -- we may only want this function for assertion checking, not as
   -- part of our normally executable code

   procedure Push ...
   --! pre not IsFull; -- run time assertion
   ...
end P;

with P;
package Q is
   procedure SomeOperation;
   -- Calls P.Push so we really need to propagate the precondition here
   --! pre not P.IsFull;
   ...
end Q;

with Q;
package R is
   procedure AnotherOperation;
   -- this calls Q.SomeOperation;
   -- It's execution will involve the check not P.IsFull but P is not
   -- visible here.
end R;

The really difficult cases are those that involve indirect manipulation 
of global data in remote packages.  These problems are worst when trying 
to express a postcondition that depends on the initial values of that 
global data.

SPARK avoids these problems by having two different sets of scopes: 
program (i.e. Ada) context and proof context.  In the above example, we 
would make IsFull a proof function (i.e. not part of the executable 
code) and make use of "inherit" to make it visible without having to 
increase the number of with clauses.

regards


Peter




  parent reply	other threads:[~2003-03-25  8:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-23 18:55 Ada and Design By Contract Volkert
2003-03-24  9:41 ` Lutz Donnerhacke
2003-03-24 10:56 ` Peter Amey
2003-03-24 17:40   ` Volkert
2003-03-24 20:11     ` Lutz Donnerhacke
2003-03-25  8:04       ` Volkert
2003-03-25  8:25     ` Peter Amey [this message]
2003-03-25  9:55       ` Colin Paul Gloster
2003-03-25 10:09         ` Peter Amey
2003-03-26  9:00       ` Volkert
2003-03-26  9:38         ` Peter Amey
2003-03-26 19:00           ` Randy Brukardt
2003-03-26 19:32           ` Jeffrey Carter
2003-03-27  6:59             ` Volkert
2003-03-26  9:00       ` Volkert
2003-03-25 10:44 ` 
replies disabled

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