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.93.230 with SMTP id cx6mr1281711wib.5.1363394825069; Fri, 15 Mar 2013 17:47:05 -0700 (PDT) Path: bp2ni94602wib.1!nntp.google.com!feeder1.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feed.tweaknews.nl!85.12.40.130.MISMATCH!xlned.com!feeder1.xlned.com!news.astraweb.com!border2.a.newsrouter.astraweb.com!newsfeed10.multikabel.net!multikabel.net!newsfeed20.multikabel.net!news.mi.ras.ru!goblin-spool!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, 13 Mar 2013 14:31:54 +0100 Organization: cbb software GmbH Message-ID: References: <8klywqh2pf$.1f949flc1xeia.dlg@40tude.net> <513f6e2f$0$6572$9b4e6d93@newsspool3.arcor-online.net> <513faaf7$0$6626$9b4e6d93@newsspool2.arcor-online.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-13T14:31:54+01:00 List-Id: On Wed, 13 Mar 2013 10:45:54 +0100, J-P. Rosen wrote: > Le 13/03/2013 09:49, Dmitry A. Kazakov a �crit : >> In Ada subtype >> (here subtype is Ada-subtype) operations are inherited per composition with >> conversion to the base type which is null for in-arguments and sometimes >> range-check of outs (not always, though). E.g. >> >> F (X : S) = F (S'Base (X)) >> >> S is a subtype *because* it inherits F. > > Not at all. In Ada, a type is a set of values. A type is a set of values bound by operations defined on them. It is values+operations. Even under your (wrong) definition Positive is still different from Integer because Positive does not have values like -1. > A subtype is the SAME > TYPE, restricted to a subset of the values (the "constraint"). There is a simple empiric test to determine if two types are same. They are if there is no language means to distinguish them either at compile or at run-time. Ada subtypes are proper types and they are distinguishable from each other and their bases. E.g. these two programs are not equivalent: X : Integer := -1; and X : Positive := -1; You cannot replace Integer with Positive without changing the semantics of any possible program, hence they are different. Note that since the above is the weakest possible definition of dissimilarity. Any other would be only stronger. Therefore, there is no way to have Ada's Positive and Integer "same." > A subtype has the same operation > as its base type, not copies of the operations as with inheritance. In a typed language any type has only operations of its own. All other operations give type error. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de