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: a07f3367d7,73cb216d191f0fef X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII X-Received: by 10.180.20.239 with SMTP id q15mr1245164wie.7.1364344222286; Tue, 26 Mar 2013 17:30:22 -0700 (PDT) Path: p18ni19762wiv.0!nntp.google.com!feeder1.cambriumusenet.nl!82.197.223.103.MISMATCH!feeder3.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsgate.cuhk.edu.hk!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Is this expected behavior or not Date: Wed, 20 Mar 2013 11:04:45 +0100 Organization: cbb software GmbH Message-ID: References: <5140f1ad$0$6634$9b4e6d93@newsspool2.arcor-online.net> <7jct0noryc1v.1rnj5kkzx6m35.dlg@40tude.net> <5141c499$0$6642$9b4e6d93@newsspool2.arcor-online.net> <18r2kop6fyozu.tctrjnghfxqs.dlg@40tude.net> <1wv3p3nrtejfk$.bwebhg9agt0l.dlg@40tude.net> <514874d3$0$6628$9b4e6d93@newsspool2.arcor-online.net> <1o60gooo8xvba$.1ei9cebb07zek$.dlg@40tude.net> <514897bd$0$6641$9b4e6d93@newsspool2.arcor-online.net> <1oqwvcemo8dha$.hevuedtz8eze.dlg@40tude.net> <14aijp8ckzahf$.1ilfm1nw6qgyt$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Date: 2013-03-20T11:04:45+01:00 List-Id: On Tue, 19 Mar 2013 22:59:22 +0100, J-P. Rosen wrote: > Le 19/03/2013 21:45, Dmitry A. Kazakov a �crit : >>>> Subtype is a type that inherits some operations (interface) of another >>>> >> type, called "parent type," "base type," "ancestor type" or "supertype." >>> > >>> > This may be the source of the confusion. What you describe is called >>> > "subtype" in other languages, but this is called "derived type" in Ada. >>> > An Ada subtype is a completely different beast, that does not correspond >>> > to this definition. >> And how is it different? >> > It is different in that a subtype does NOT inherit operations, it has > the SAME operations as its type. How do you know that they are same? In what sense are they same? But they are evidently not same: procedure Foo (X : out Integer) is begin X := -1; end Foo; when inherited by Positive changes its behavior. > Proof: a fundamental feature of OOP is that you can redefine inherited > operations. You cannot redefine operations of a subtype to be different > from those of its type. But they are redefined. The compiler adds conversion to the subtype for each in-argument and conversion from the subtype for each out-argument. Which is what happens with Foo above the body of procedure Foo (X : out Positive) is the body of procedure Foo (X : out Integer) + constraint check. > Note also that a subtype is a property of an object; a value has no > subtype, only a type. No, subtyping is a relation between two types, denoted as T<:S. Object has no subtype, it has a type. So does a value. >Therefore, it would not be possible to dispatch > according to the subtype, since you would not know which operation to > use if the controlling operand is a plain value. It is impossible to dispatch on a specific type anyway. Dispatching happens only on a class-wide type. Integer and Positive indeed form a class, but Ada, presently, has no type corresponding to that class, e.g. Integer'Class. If it had, and if you had an object of the type Integer'Class, then you could dispatch. Which is BTW, a highly desired improvement which would for example sort out the mess we have with string types. > Now, you can argue that these are all more flaws of Ada - or recognize > at last that a subtype is not a different type. Not at all. Ada 83 subtypes are consistent with the type model when they are considered abstract data types, as they surely are. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de