comp.lang.ada
 help / color / mirror / Atom feed
From: randhol+abuse@pvv.org (Preben Randhol)
Subject: Re: Types vs subtypes
Date: 29 Aug 2000 06:06:45 GMT
Date: 2000-08-29T06:06:45+00:00	[thread overview]
Message-ID: <slrn8qmklo.15j.randhol+abuse@kiuk0156.chembio.ntnu.no> (raw)
In-Reply-To: 39AAF3AB.3E5EE43E@ix.netcom.com

On Mon, 28 Aug 2000 16:20:11 -0700, Richard Riehle wrote:
>
>This is something that comes up a lot in my Ada classes.   I try to explain it
>this way:
>
>A type has
>                      1)  a name
>                      2)  a set of operations
>                      3)  a set of values
>                      4)  a wall between objects of itself and objects of other
>types with differing type names
>
>The last item, " a wall" is important in distinguishing structural equivalence
>from name equivalence in the
>Ada type system.
>
>A subtype has
>
>                     1)  a name
>                     2)  a parent type
>                     3)  the set of operations of its parent type
>                     4)  either the same set of values of its parent type or a
>constrained set of values
>                     5)  no wall between operations between itself and its
>parent type
>                     6)  no wall between itself and other subtypes derived from
>its parent or from itself
>
>A subtype is structurally equivalent to its parent type and its subtype
>siblings, but may have a smaller
>range of legal values.

Yes. I like to look at it in this (rough) way in accordance with the
syntax :

    type Height is new Integer;
    --          ^^^^^^
    -- Think of it as a new type.

    subtype Height is Integer;
    --             ^^
    -- Think of it as it _is_ Integer type and not a new one.

-- 
Preben Randhol - Ph.D student - http://www.pvv.org/~randhol/
"i too once thought that when proved wrong that i lost somehow"
                               - i was hoping, alanis morisette



      parent reply	other threads:[~2000-08-29  6:06 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
2000-08-29  0:00     ` Jean-Pierre Rosen
2000-08-29  6:06   ` Preben Randhol [this message]
replies disabled

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