home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!telesoft!garym
- From: garym@telesoft.com (Gary Morris @pulsar)
- Subject: Re: Novice Question on Record Representation
- Message-ID: <1992Dec17.182403.6353@telesoft.com>
- Organization: Alsys Group, San Diego, CA, USA
- References: <1992Dec16.225712.23791@saifr00.cfsat.honeywell.com> <dnsurber.724602575@node_26400>
- Date: Thu, 17 Dec 1992 18:24:03 GMT
- Lines: 27
-
- In <dnsurber.724602575@node_26400> dnsurber@lescsse.jsc.nasa.gov (Douglas N. Surber) writes:
- > package P1 is
- > type T is private;
- > T_Size : constant := 32;
- > private
- > type T is new Integer;
- > subtype Assertion is boolean range true .. true;
- > a1 : constant Assertion := T_Size = T'Size;
- > end P1;
-
- >By using the Assertion, you assure that T_Size has the right value. Yes,
- >you may have to tweak its value when you port, but you can't get a clean
- >compile with the wrong value so it is safe.
-
- Unfortunately, you can't rely on assertion like this. The constant a1 is
- not used anywhere and an optimizing compiler could remove a1 and the
- expression used for its initial value (TSize = T'Size). So the range check
- never occurs and no exception or compile time warning is generated. This
- optimization is allowed by 11.6(7), when the only effect of a predefined
- operation is to raise an exception.
-
- --GaryM
- --
- Gary Morris Internet: garym@telesoft.com
- Ada Software Development UUCP: uunet!telesoft!garym
- Alsys West (TeleSoft) Phone: +1 619-457-2700
- San Diego, CA, USA Fax: +1 619-452-2117
-