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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,5a88548f1bcf3510 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Received: by 10.66.73.7 with SMTP id h7mr880510pav.6.1353058332532; Fri, 16 Nov 2012 01:32:12 -0800 (PST) MIME-Version: 1.0 Path: 6ni83173pbd.1!nntp.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!novia!news-hub.siol.net!news1.t-com.hr!newsfeed.CARNet.hr!newsfeed.x-privat.org!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Overring function and its returned type Date: Sat, 10 Nov 2012 01:55:11 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1352534118 5189 69.95.181.76 (10 Nov 2012 07:55:18 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sat, 10 Nov 2012 07:55:18 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Response X-Received-Bytes: 3686 Date: 2012-11-10T01:55:11-06:00 List-Id: "Yannick Duch�ne (Hibou57)" wrote in message news:op.wnhvol1wule2fv@cardamome... > procedure Ex is > > -- ======================================== > > package P1 is > > type R is interface; > type T is interface; > > not overriding > function F > (E : T) > return R'Class > is abstract; > end; > > -- ======================================== > > package P2 is > > type R is interface and P1.R; > type T is interface and P1.T; > > overriding > function F > (E : T) > return R'Class -- Not overriding :-( > is abstract; > end; > > -- ======================================== I'd strongly suggest to use different names for different types in examples, otherwise you'll confuse everyone (and yourself). Just because you can use the same name in the real code (and might want to in unusual circumstances) is no good reason to make examples that confuse the heck out of everyone. In any case, overriding requires subtype conformance. And if you properly named the types, the problem would be obvious. package P2 is type R2 is interface and P1.R; type T2 is interface and P1.T; overriding function F (E : T2) return R2'Class -- Not overriding :-( is abstract; end; Since overriding requires subtype conformance (among other things, requiring the same subtype on all non-controlling parameters and results), and R2'Class /= R'Class (and this isn't a controlling result), no overriding is possible. There are good reasons for these restrictions (mostly implementation-oriented). I'm sure there exist (very limited) cases where it might make sense to relax subtype conformance, but there would need to be a strong justification for the significant added complication in the language rules and implementation. I'm pretty certain that an example using types T and R isn't it. In any case, Ada 2012 is finished (with possibility of some editorial corrections in the final edition, but nothing substansive). If we were going to fix anything in it, it would be the handful of bad bugs that have been identified, surely nothing involving features that are unchanged in Ada 2012 (which is the case with overriding, modulo wording bugs). Randy.