comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: types and subtypes
Date: Tue, 14 Mar 2006 09:47:04 +0100
Date: 2006-03-14T09:47:04+01:00	[thread overview]
Message-ID: <1x3fms4agogjf.2u1s46ucfw7u.dlg@40tude.net> (raw)
In-Reply-To: 1142273325.634632.41020@j52g2000cwj.googlegroups.com

On 13 Mar 2006 10:08:45 -0800, ada_student@yahoo.com wrote:

> A type also defines the set of values that an object can have.
> If an Ada subtype adds a constraint to an Ada type, then the
> subtype is a type that is a derivative(derivative as in the Ada
> sense) of the Ada type and is different from that type.

Yes it is, but that does not prevent the new type to have the same
representation and be substitutable for the base one. You can consider a
subtype as a new type for which the compiler routinely applies identity
conversions. Downward conversions additionally check the constraint. So it
is consistent with strong typing, and the notion of subtype is nothing but
just a type relation. There is nothing except types.
 
> [I know you can say "type T2 is new T1 ..." in Ada to denote
> derivation]

That was IMO a bad design decision. It should be "subtype T2 is T1 with".
But that's my personal opinion.

> Why doesnt Ada subtyping also denote derivation as in the
> sense C++ base classes and derived classes do?
> 
> Why was Ada's subtyping defined to exclude derivation?

Probably because it seemed conceptually simpler. Ada 83 had subtype = same
representation + constraint. Ada 95 added derived tagged extension = same
representation + extension part. If we drop "same representation", which is
clearly an implementation detail, we will see that there is no difference.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2006-03-14  8:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-13 12:07 types and subtypes ada_student
2006-03-13 13:20 ` Jean-Pierre Rosen
2006-03-13 18:08   ` ada_student
2006-03-13 18:17     ` Ed Falis
2006-03-13 19:14     ` Larry Kilgallen
2006-03-13 19:42     ` Martin Krischik
2006-03-13 20:22     ` Wilhelm Spickermann
2006-03-14  8:47     ` Dmitry A. Kazakov [this message]
2006-03-14 14:39     ` Jean-Pierre Rosen
2006-03-17  1:24     ` Peter C. Chapin
replies disabled

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