comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: Assertions in Ada
Date: 1997/08/21
Date: 1997-08-21T00:00:00+00:00	[thread overview]
Message-ID: <EF9nDu.EIK.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: adaworksEF8qn5.I15@netcom.com


AdaWorks (adaworks@netcom.com) wrote:

: ...
: These could be pragmas in the general form,

:     pragma Require(Entity, Data-type, Boolean-Expression)

I'm not sure what the "Entity" and "Data-type" arguments signify,
but the basic ability to introduce an assertion is supported
in the Ada 95 compilers from GNAT, Aonix, Green Hills, and
Intermetrics (and perhaps others) via:

    pragma Assert(<boolean_expression> [, <string>]);

I would hope that most other Ada 95 vendors now or would
soon support this as well.

This can accomplish many of the same goals as the Eiffel mechanisms,
though it is not associated with a type/class, but rather with a 
particular point in the execution (which is undeniably less powerful).  
A pragma Assert does not support the ability to specify a loop "variant," 
at least not without the programmer adding some extra variables.

Note that during the 9X design we did consider adding more complete
assertion/invariant constructs, but dropped them in the desire to
reduce the overall scope of the revision.

The Eiffel mechanisms are certainly interesting, though I 
believe the class-oriented assertions are in fact a bit 
limiting, in that one must write only assertions that all
subclasses can satisfy.  There is less support for writing assertions
that apply only to a class, but not to its subclasses.  Such 
class-specific assertions make good sense and can help in debugging 
and proving correctness of a particular class, even though they do 
not apply to subclasses.

My biggest complaint about Eiffel (and Java, for that matter), however, 
is that they don't physically separate interface from implementation (except 
via the notion of "deferred" classes).  The normal response is that
you can use a tool to "extract" the interface any time you want,
but that seems to break the whole notion of "design by contract."
I would never go to an implementor and ask them "what is today's
contract?"  The contract should be a separate entity (e.g. the
package spec) which does not "belong" to (and is not extracted from)
either the client or the implementation of the abstraction.
The compiler can then check conformance of an implementation against
its contract.  If you bundle the interface with the implementation,
then there is nothing against which the compiler can check conformance.

It is sort of like answering the question "what does it do?" with the
answer "it does what it does."

I realize that assertions can represent a contract, but the
parameter/result profile is also an important kind of contract
(especially when it includes parameter modes, as it does in Ada).
And if assertions are the only form of separate contract, they
are less useful if they cannot be class-specific, but must
always be constructed in a way that they can apply to any
subclass as well.

: ...
: Richard Riehle
: richard@adaworks.com
: AdaWorks Software Engineering

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA




  reply	other threads:[~1997-08-21  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-08-21  0:00 Assertions in Ada AdaWorks
1997-08-21  0:00 ` Tucker Taft [this message]
     [not found]   ` <JSA.97Aug21183650@alexandria.organon.com>
1997-08-21  0:00     ` Robert Dewar
1997-08-22  0:00       ` Tucker Taft
1997-08-23  0:00         ` Ken Garlington
1997-08-24  0:00           ` Brian Rogoff
     [not found]         ` <199708251351.PAA13197@basement.replay.com>
1997-08-25  0:00           ` Robert Dewar
1997-08-27  0:00             ` Adrian P. Morgan
1997-08-31  0:00               ` Robert A Duff
1997-08-21  0:00   ` Brian Rogoff
1997-08-22  0:00     ` Robert Dewar
1997-08-23  0:00   ` Ken Garlington
1997-08-24  0:00     ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1997-08-22  0:00 AdaWorks
replies disabled

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