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,49c69fcb0de2bb74 X-Google-Attributes: gid103376,public From: "Marc A. Criley" Subject: Re: Types vs subtypes Date: 2000/08/29 Message-ID: <39ABAAE7.3B4BEF29@lmco.com>#1/1 X-Deja-AN: 663863649 Content-Transfer-Encoding: 7bit References: <39a9d2b0@duster.adelaide.on.net> <39AAF3AB.3E5EE43E@ix.netcom.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.vf.lmco.com X-Trace: knight.vf.lmco.com 967551208 17502 166.17.160.57 (29 Aug 2000 12:13:28 GMT) Organization: Lockheed Martin M&DS Mime-Version: 1.0 NNTP-Posting-Date: 29 Aug 2000 12:13:28 GMT Newsgroups: comp.lang.ada Date: 2000-08-29T12:13:28+00:00 List-Id: Richard Riehle wrote: >A subtype is structurally equivalent to its parent type and its subtype >siblings, but may have a smaller >range of legal values. Actually, there's a specific situation where this statement could be interpreted as not necessarily being true--depending on how broadly one defines "structural equivalence". And which came as a surprise to us. We had a situation where there was a type Counts is range 0..128; that had a size clause: for Counts'Size use 32; This then had a subtype subtype Indicies is Counts range 1..128; Our expectation was that Counts'Size would be 32, and Indices'Size would be 32. While that was in fact the case for the 'Size of Counts, Indices'Size turned out to be 8. We researched this in the RM (and could find no statement requiring that a type's size be passed on to its subtypes), and also went back to our compiler vendor, and confirmed that this behavior was correct. It was, as Robert Dewar put it, "in pure Ada 95...a nasty omission". While size specification is retained through derivation, it is not through subtyping. And placing a Size specification on a subtype is not permitted by the language. We ended up utilizing the parent type in the external interface, relying on the use of the subytpe throughout the remainder of the module to ensure the proper constraints were obeyed. Marc A. Criley Software Architect Lockheed Martin M&DS