comp.lang.ada
 help / color / mirror / Atom feed
From: "Marc A. Criley" <marc.a.criley@lmco.com>
Subject: Re: Types vs subtypes
Date: 2000/08/29
Date: 2000-08-29T12:13:28+00:00	[thread overview]
Message-ID: <39ABAAE7.3B4BEF29@lmco.com> (raw)
In-Reply-To: 39AAF3AB.3E5EE43E@ix.netcom.com

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






  reply	other threads:[~2000-08-29  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-28  2:47 Types vs subtypes Alex Angas
2000-08-28  0:00 ` Richard Riehle
2000-08-29  0:00   ` Marc A. Criley [this message]
2000-08-29  0:00     ` Jean-Pierre Rosen
2000-08-29  6:06   ` Preben Randhol
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox