comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nickroberts@callnetuk.com>
Subject: Re: Assertions
Date: 1999/05/19
Date: 1999-05-19T00:00:00+00:00	[thread overview]
Message-ID: <3742eba6@eeyore.callnetuk.com> (raw)
In-Reply-To: 7hqe7m$q7i@sjx-ixn1.ix.netcom.com

Richard D Riehle wrote in message <7hqe7m$q7i@sjx-ixn1.ix.netcom.com>...
[...]
|    pragma Pre_condition  (boolean_expression [ ... ]);
|    pragma Post_condition (boolean_expression [ ... ]);


What would these actually do that Assert would not?

|    pragma Invariant      (boolean_expression [ ... ]);


This construct (I think) could be replaced by an Assert repeated in several
places.  Would it be so useful as to be worthwhile?  (Perhaps it would.)

|   with the further suggestion that we adopt Require, Ensure, and
|   Invariant from the Eiffel language.


For those of us Eiffel non-cognoscienti, what do these do, please?

|   One must be careful with assertions as pragmas.  It is quite
|   possible to declare a non-sensical assertion that is never
|   detected by the compiler.  When declaring assertions for a
|   derivation class, one can construct a boolean expression that
|   holds for the root of the class but fails for some derived type.

'Twas ever thus.  In all cases, the programmer must be as careful to put
something sensible into an Assert as into the code proper.

Assertions are certainly no panacea: sometimes the code to check up on a
piece of code would be more complex to write than the code it's checking;
sometimes there is no practical way to check up on it at all; M****y's L*w
ensures that bugs can get into the checking code as easily as they can get
into the code proper (and be just as much of a S*****g B****r to root out
;-).

|   This is a fundamental problem with assertions.  The more conservative
|   approach of Ada, in which every type is invariant tends to be more
|   appropriate for safety-critical software.  If there were some way
|   to formally prove, through a software routine, that an assertion
|   did not resolve to some completely silly set of propositions during
|   the derivation process, we might be more inclined to depend on them.
|   As things stand now, assertion pragmas, while a good idea on the
|   surface, could easily create more problems than they solve.


I would be grateful if you would expand a little on this, perhaps giving an
example or two.

I apologise to those who don't wish to retread this well-trodden ground, but
there some of us who missed the boat first time around, and need to retread
it.

-------------------------------------
Nick Roberts
-------------------------------------







  reply	other threads:[~1999-05-19  0:00 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-10  0:00 Assertions J & A Richardson
1999-05-10  0:00 ` Assertions Marin David Condic
1999-05-11  0:00   ` Assertions Robert Dewar
1999-05-11  0:00     ` Assertions Nick Roberts
1999-05-11  0:00       ` Assertions Robert Dewar
1999-05-12  0:00         ` Assertions Dale Stanbrough
1999-05-12  0:00           ` Assertions Robert Dewar
1999-05-12  0:00     ` Assertions Tucker Taft
1999-05-12  0:00       ` Assertions Larry Kilgallen
1999-05-12  0:00         ` Assertions Tucker Taft
1999-05-13  0:00         ` Assertions Nick Roberts
1999-05-17  0:00           ` Assertions Dale Stanbrough
1999-05-19  0:00             ` Assertions Nick Roberts
1999-05-22  0:00               ` Assertions Dale Stanbrough
1999-05-22  0:00                 ` Assertions Ray Blaak
1999-05-22  0:00                   ` Assertions Robert Dewar
1999-05-23  0:00                     ` Assertions Nick Roberts
1999-05-24  0:00                       ` Assertions Dale Stanbrough
1999-05-24  0:00                       ` Assertions Ray Blaak
1999-05-22  0:00                 ` Assertions Robert Dewar
1999-05-23  0:00                 ` Assertions Nick Roberts
1999-05-12  0:00       ` Assertions Marin David Condic
1999-05-18  0:00       ` Assertions Richard D Riehle
1999-05-19  0:00         ` Nick Roberts [this message]
1999-05-19  0:00           ` Assertions Richard D Riehle
1999-05-20  0:00             ` Assertions stimuli
1999-05-21  0:00               ` Assertions Richard D Riehle
1999-05-21  0:00                 ` Assertions Robert Dewar
1999-05-20  0:00             ` Assertions Ehud Lamm
1999-05-21  0:00               ` Assertions Robert Dewar
1999-05-21  0:00                 ` Assertions Ehud Lamm
1999-05-21  0:00                   ` Assertions Tucker Taft
1999-05-20  0:00           ` Assertions stimuli
1999-05-12  0:00 ` Assertions Peter Amey
1999-05-12  0:00   ` Assertions Robert Dewar
replies disabled

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