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.8 required=5.0 tests=BAYES_00, BUG6152_INVALID_DATE_TZ_ABSURD autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6401faa712588412,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-17 08:50:03 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed2.news.rcn.net!rcn!dca6-feed2.news.digex.net!intermedia!netnews.jhuapl.edu!not-for-mail From: Jonathan DeSena Newsgroups: comp.lang.ada Subject: Access to tagged type parameters Date: Fri, 17 Aug 2001 11:44:40 +0228 Organization: JHU/APL Message-ID: <9lje36$ijn$1@houston.jhuapl.edu> NNTP-Posting-Host: desenjt1.jhuapl.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: houston.jhuapl.edu 998063014 19063 128.244.68.35 (17 Aug 2001 15:43:34 GMT) X-Complaints-To: usenet@houston.jhuapl.edu NNTP-Posting-Date: 17 Aug 2001 15:43:34 GMT User-Agent: KNode/0.6.1 Xref: archiver1.google.com comp.lang.ada:12053 Date: 2001-08-17T15:43:34+00:00 List-Id: According to Cohen's "Ada as a Second Language," which I've been using to pick up Ada95 in my spare time: "All formal parameters belonging to tagged types are implicitly declared to be aliased. This allows a subprogram to create access values pointing to its tagged formal parameters using the 'Access attribute ..." (section 12.6.2, page 579 in my version) This is the ONLY reference to this in the book I can find; there are no examples of it's use, though it seems simple enough. However, no matter what I try, I can't seem to get such code to compile using gnat 3.13p on Debian/Linux (Intel). I continually get the following error: non-local pointer cannot point to local object Here's a code snippet which I've been using as a test case -- it doesn't do anything, but I just use it to see if it will compile: --start test.adb with Ada.Text_IO; procedure Test is type A_Type is tagged record A1:Integer; --just to fill the record with something A2:Integer; end record; type A_Access_type is access all A_Type'Class; procedure A_Test (B:in out A_Type'Class) is B_Access: A_Access_Type; begin B_Access:=B'Access; Ada.Text_IO.Put_Line("Done."); end A_Test; C:A_Type; begin A_Test(C); end Test; --end test.adb Does anyone know if this works as advertised? Or maybe I am misunderstanding the statement in the book? Anyone have a similar example to the above that DOES work? 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. Thanks in advance. jtd