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-7-bit X-Google-Thread: 103376,6401faa712588412 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-17 14:45:19 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.gtei.net!newshub2.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Access to tagged type parameters References: <9lje36$ijn$1@houston.jhuapl.edu> X-Newsreader: Tom's custom newsreader Message-ID: Date: Fri, 17 Aug 2001 21:45:18 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 998084718 24.7.82.199 (Fri, 17 Aug 2001 14:45:18 PDT) NNTP-Posting-Date: Fri, 17 Aug 2001 14:45:18 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:12077 Date: 2001-08-17T21:45:18+00:00 List-Id: >I'd like to be able to use access values to a tagged type in a subprogram >which has the type itself as a parameter rather than an access type. That >way, when the tagged type is inherited, the subprograms will go with it. >Subprograms which only have access types to the tagged type do not get >inhereted by the derived type it seems. "A subprogram declared ... is a primitive operation of that type if it has a parameter of type T, an access parameter pointing to objects of type T, ..." Ada as a language, bottom of p. 504 >non-local pointer cannot point to local object Consider: type A_Type is tagged record ... type A_Access_type is access all A_Type'Class; Outer_B : A_Access_Type; procedure A_Test (B:in out A_Type'Class) is B_Access: A_Access_Type; begin B_Access:=B'Access; Outer_B := B_Access; Ada.Text_IO.Put_Line("Done."); end A_Test; procedure Test is X : A_Type; begin A_Test(X); end Test; begin Test; Outer_B.all := .... -- what does this point to??? A local object, X, disappears while a non-local pointer, Outer_B, is still pointing to it. You need to make "type A_Access_Type" more local so any such pointer will be guaranteed to disappear no later than anything it points to.