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,33ed4ca582c945fc X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Limited returns Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <7ab69a86-cfcf-4dba-9280-e0fce906ed76@x1g2000prh.googlegroups.com> Date: Mon, 23 Jun 2008 19:03:24 +0200 Message-ID: NNTP-Posting-Date: 23 Jun 2008 19:03:28 CEST NNTP-Posting-Host: 992db569.newsspool2.arcor-online.net X-Trace: DXC=cK\TYnSOiR6NTD55K=A9EHlD;3Yc24Fo<]lROoR18kFJ``68^M;=[6LHn;2LCV>COgUkn_?_Y?4RhJRkCnE@454PGBcl: On Mon, 23 Jun 2008 08:15:12 -0700 (PDT), Adam Beneschan wrote: > On Jun 23, 7:21 am, "Dmitry A. Kazakov" > wrote: >> Let's consider this: >> >> with Ada.Finalization; >> procedure Test_Limited_Stuff is >> type I is limited interface; >> >> type T is new Ada.Finalization.Limited_Controlled with record >> A : Integer; >> end record; >> >> type S is new T and I with record >> Self : not null access S'Class := S'Unchecked_Access; >> end record; >> >> function Factory return I'Class is >> begin >> return X : S; >> -- GNAT: wrong type for return_subtype_indication >> end Factory; >> begin >> null; >> end Test_Limited_Stuff; >> >> Is it illegal? I am surprised why? S is in I'Class. > > It's illegal, but hopefully not for long. See: > > http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AI05s/AI05-0032-1.TXT?rev=1.4 It would be nice, because this "feature" is extremely boring. > Perhaps you could ask your compiler to go ahead and implement that AI > (or at least the part of it that allows the specific return type as > you've done). I think it was just an oversight in Ada 2005 not to > allow this. Is there an AI to finally fix a similar problem with pool-specific access types? I mean this: procedure Test_Access is type T is tagged null record; type S is new T with null record; type T_Ptr is access T'Class; type S_Ptr is access S'Class; function Factory return T_Ptr is X : S_Ptr := new S; begin .. -- Do something with X return T_Ptr (X); -- Illegal!??? end Factory; begin null; end Test_Access; The only workaround is to cast: function Factory return T_Ptr is Result : P_Ptr := new S; X : S'Class renames S'Class (Result.all); begin .. -- Do something with X return Result; end Factory; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de