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,73cb216d191f0fef X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.183.180 with SMTP id en20mr4587637wic.3.1363164489295; Wed, 13 Mar 2013 01:48:09 -0700 (PDT) Path: g1ni63097wig.0!nntp.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!78.46.240.70.MISMATCH!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!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 09:49:22 +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="us-ascii" Content-Transfer-Encoding: 7bit Date: 2013-03-13T09:49:22+01:00 List-Id: On Tue, 12 Mar 2013 23:23:52 +0100, Georg Bauhaus wrote: > On 12.03.13 19:21, Dmitry A. Kazakov wrote: >> On Tue, 12 Mar 2013 19:04:31 +0100, Georg Bauhaus wrote: >> >>> On 12.03.13 18:42, Dmitry A. Kazakov wrote: >>>> On Tue, 12 Mar 2013 13:19:06 -0400, Robert A Duff wrote: > >>>>>> The profile of 'Succ is given in RM-3.5(23): >>>>>> >>>>>> function S'Succ (Arg: S'Base) return S'Base; >>>>>> >>>>>> It's neither contravariant nor covariant -- it's invariant. >>>> Invariant = contravariant. >>> >>> In Ada? For non-tagged types? >> >> Tagged is a special case, nothing more. >> >> When the compiler allows instances of Prime in an operation of Prime'Base >> that means that Prime inherits the operation > > No inheritance involved here, in Ada, where the object involved simply is of > an unconstrained subtype of the given type of Prime, which is not Prime. You have two types T and S and one operation F. Provided Ada is a typed language. F (X : T) shall not accept S, unless inherited. 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. All three statements are equivalent: 1. S is a subtype of T 2. S inherits operations of T 3. S is substitutable in operations of T (syntactically, not LSP) When you inherit with null-conversion, as it is the case with 'Succ you break the semantics of the result, which is not new. It is well-known LSP issue that contravariance of out-arguments/results is broken upon specialization. Which is trivial to see. Prime is not a subtype which can preserve Integer's 'Succ. Nothing can be done about it. Neither can Prime preserve +,-,*,/. Prime is basically not Integer. Not every set of integers is Integer, and subsetting /= subtyping. > This type, not Prime (which isn't a type), How so? Subtype certainly is a type. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de