From: Ray Blaak <blaak@infomatch.com>
Subject: Re: Assertions
Date: 1999/05/24
Date: 1999-05-24T00:00:00+00:00 [thread overview]
Message-ID: <ur9o6cy0i.fsf@infomatch.com> (raw)
In-Reply-To: 37484098@eeyore.callnetuk.com
"Nick Roberts" <nickroberts@callnetuk.com> writes:
> pragma Assume (Condition);
> pragma Verify (Condition);
I would also allow optional description strings that would be part of the
raised exception, accessible via Ada.Exceptions. Most importantly, the strings
would be evaluated only if Condition is False:
pragma Assume (Condition [, description]);
pragma Verify (Condition [, description]);
This would eliminate once and for all code like:
if Debug and not Condition then
Verify (False, "complicated string that should be evaluated only "
& "when necessary: " & DescriptionOf (currentObject));
end if;
> For all four of these pragmas, if the test of the Condition is actually
> done, and it fails (evaluates to False), the predefined exception
> Program_Error is raised. (If this exception is raised by a pragma which
> takes the place of a declaration, the exception is immediately propagated
> out the innermost enclosing block, and is never handled by an exception
> handler inside this block.)
I would suggest another exception name, so that one can distinguish the fact
that a programmer-defined check failed, as opposed to a mistake in
general. Maybe: Assertion_Error, or both Verification_Error and
Assumption_Error.
> It may well be better to use 'Assert' throughout rather than 'Verify'.
> Comments please.
Well, "Assert" gives rise to discussions as to what it really means,
especially in comp.lang.ada :-). The idea is to side-step the issue by letting
the programmer decide which type of assertion is desired. Whatever names are
chosen should clearly reflect the intention.
--
Cheers, The Rhythm is around me,
The Rhythm has control.
Ray Blaak The Rhythm is inside me,
blaak@infomatch.com The Rhythm has my soul.
next prev parent reply other threads:[~1999-05-24 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 Marin David Condic
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 Robert Dewar
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 ` Ray Blaak [this message]
1999-05-23 0:00 ` Assertions Nick Roberts
1999-05-18 0:00 ` Assertions Richard D Riehle
1999-05-19 0:00 ` Assertions Nick Roberts
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