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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC 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: Marin David Condic Subject: Re: Assertions Date: 1999/05/10 Message-ID: <3736F549.E3DDCDEB@pwfl.com>#1/1 X-Deja-AN: 476196580 Content-Transfer-Encoding: 7bit Sender: condicma@bogon.pwfl.com References: <3736D243.1EEBF1AB@globalnet.co.uk> Content-Type: text/plain; charset=us-ascii Organization: Pratt & Whitney Mime-Version: 1.0 Reply-To: diespammer@pwfl.com Newsgroups: comp.lang.ada Date: 1999-05-10T00:00:00+00:00 List-Id: J & A Richardson wrote: > > I have looked through the RM and can not find any refference to > assertions, pre conditions, or post conditions. > > It was my understanding that Ada 95 used assertions. > > I have also looked through a couple of webpages. > > Does Ada 95 use exceptions to work as assertions? Or am I missing > something? > That depends on exactly what will count as an "assertion". If parameters to a procedure are of data types that have meaningful constraints (ranges for which the subprogram is valid) then this counts as a kind of primitive assertion. Violation of the assertion will raise an exception. But I don't think that is what you mean. The sort of assertions that would allow you to check for, say, relationships between parameters as well as valid ranges, etc., are not a standard part of Ada. However, the GNAT compiler for Ada95 has the pragma Assert which allows you to include logical expressions which can be turned on and off with compiler directives. This lets you accomplish the same thing as a direct language feature in creating preconditions, postconditions, etc. I won't swear to it, but I think the "pragma Assert" got enough attention that other compiler vendors have implemented it as well, so it is becoming a common - if not standard - feature of the language. I'd expect to see it in some future revision of the ARM. MDC -- Marin David Condic Real Time & Embedded Systems, Propulsion Systems Analysis United Technologies, Pratt & Whitney, Large Military Engines M/S 731-95, P.O.B. 109600, West Palm Beach, FL, 33410-9600 ***To reply, remove "bogon" from the domain name.*** Visit my web page at: http://www.flipag.net/mcondic