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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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.106.73 with SMTP id gs9mr1242896wib.2.1364344248401; Tue, 26 Mar 2013 17:30:48 -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!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Is this expected behavior or not Date: Wed, 20 Mar 2013 12:01:25 +0100 Organization: A noiseless patient Spider 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> Mime-Version: 1.0 Injection-Date: Wed, 20 Mar 2013 10:59:31 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="38a7d8e63badbc37d4b5295d05d51fdb"; logging-data="23465"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Y+sj1s7PlTK/fjJ8u9NQx" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 In-Reply-To: Cancel-Lock: sha1:FVzm3+eLtlzmPyxoG9sItIE6HsI= X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: 2013-03-20T12:01:25+01:00 List-Id: Le 20/03/2013 11:04, Dmitry A. Kazakov a �crit : >> 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. They are not inherited! You can call the above Foo with a variable of type Positive; Constraint_Error is raised after the call when converting back. But once again, it is the same operation that is called by Integer and Positive. >> 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. > This is not the way it is defined in Ada, and what I said is that the user cannot redefine Foo for Positive. >> 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. In standard OO speak yes, but that is NOT the meaning in Ada. > Object has no subtype, it has a type. So does a value. An object has a subtype that defines a constraint to be checked when assigning to it. You may view or describe features of Ada any way you please (I do sometimes cheat with the official model for explanatory purposes when I'm teaching), but here we are discussing the official model of Ada, and what words mean as defined in ISO-8652:2012. The term "subtype" as defined there is not what you use it for. -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr