comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Assertions in Ada
Date: 1997/08/21
Date: 1997-08-21T00:00:00+00:00	[thread overview]
Message-ID: <dewar.872218059@merv> (raw)
In-Reply-To: JSA.97Aug21183650@alexandria.organon.com


Jon Anthony says

<<b) If a) is the expectation, then why was this pragma left out of the
   standard??  Just hadn't thought of it at the time? (oops that makes
   3)>>


It is one thing to stick this into an implementation, quite another to
formally define what you mean. In particular the whole issue of whether
the compiler can use the assertion involves some tricky business. We
found that different people had very different ideas in mind.

In GNAT (I can't speak for the other vendors)

pragma Assert (X);

is *exactly* equivalent to

  if not X then
     raise System.Assertions.Assert_Failure;
  end if;

This is a simple definition, but it is not at all what some people want. They
argued that the assert statement should not be allowed to affect the program
in any way (this is quite tricky to define exactly, in fact there is more
than one possible definition), but clearly the above equivalence does not
meet this requirement, because the compiler can assume a postcondition of
X after the assert.

We could not resolve this issue, so the feature got omitted. It's always
surprising (especially to those who do not have experience in language
design) how the simplest appearing things can turn out to be very complex.





  parent 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
1997-08-21  0:00   ` Brian Rogoff
1997-08-22  0:00     ` Robert Dewar
     [not found]   ` <JSA.97Aug21183650@alexandria.organon.com>
1997-08-21  0:00     ` Robert Dewar [this message]
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-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