From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1e5c102037393131 X-Google-Attributes: gid103376,public From: Ray Blaak Subject: Re: Assertions Date: 1999/05/24 Message-ID: #1/1 X-Deja-AN: 481526381 Sender: blaak@LANGLEY References: <3736D243.1EEBF1AB@globalnet.co.uk> <3736F549.E3DDCDEB@pwfl.com> <7h83lc$rd$1@nnrp1.deja.com> <3739CECA.6A49865B@averstar.com> <1999May12.163911.1@eisner.decus.org> <373c862b@eeyore.callnetuk.com> <3742eba5@eeyore.callnetuk.com> <7i7ei9$93v$1@nnrp1.deja.com> <37484098@eeyore.callnetuk.com> X-Complaints-To: news@bctel.net X-Trace: news.bctel.net 927557878 209.52.142.33 (Mon, 24 May 1999 07:57:58 PDT) Organization: The Transcend NNTP-Posting-Date: Mon, 24 May 1999 07:57:58 PDT Newsgroups: comp.lang.ada Date: 1999-05-24T00:00:00+00:00 List-Id: "Nick Roberts" 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.