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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,38730e01f356adfa X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!newsfeed01.chello.at!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: types and subtypes Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1142251677.837212.109000@i39g2000cwa.googlegroups.com> <1142273325.634632.41020@j52g2000cwj.googlegroups.com> Date: Tue, 14 Mar 2006 09:47:04 +0100 Message-ID: <1x3fms4agogjf.2u1s46ucfw7u.dlg@40tude.net> NNTP-Posting-Date: 14 Mar 2006 09:47:04 MET NNTP-Posting-Host: 47b4e56c.newsread2.arcor-online.net X-Trace: DXC=7kdDYLLiDK0;iAbK4FA[l4Q5U85hF6f;4jW\KbG]kaM8:YeUX299h1<0g5T4Kg6N74[6LHn;2LCV>7enW;^6ZC`4IXm65S@:3>? X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:3353 Date: 2006-03-14T09:47:04+01:00 List-Id: 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