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-Language: ENGLISH,ASCII X-Google-Thread: 103376,a9a99a861147e2f8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-20 04:39:58 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: access on function returning a class wide type Date: Wed, 20 Nov 2002 13:39:56 +0100 Message-ID: References: <20021119-223832-295143@foorum.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: fu-berlin.de 1037795996 18939034 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:31130 Date: 2002-11-20T13:39:56+01:00 List-Id: On 19 Nov 2002 21:38:32 GMT, alex wrote: >Is there a �workaround/trick� to implement this kind of think. > >package A is > type A_T is abstract tagged null record; > function Fa return A_T is abstract; > type Fa_Ptr is access function return A_T'Class; >end A; > >with A; >package B is > type B_T is new A.A_T with null record ; > function Fa return B_T; >end B; > >package body B is > function Fa return B_T is > begin return (A.A_T with null record); > end Fa; >end B; > >with A,B; >procedure Test is > Ptr : A.Fa_Ptr := B.Fa'access; -- error : LRM:8.6(28) >begin null; >end Test; > >The compiler is expecting a function returning a A_T�Class, ok I understand� >But, B_T is in the A_T�Class! You could wrap B.Fa in a function returning A_T'Class: function Fa_b return A_T'Class is begin return B.Fa; end Fa_b; The question is why do you need something like that? Sort of lazy object creation? --- Regards, Dmitry Kazakov www.dmitry-kazakov.de