From: Jonathan DeSena <jonathan.desena@jhuapl.edu>
Subject: Access to tagged type parameters
Date: Fri, 17 Aug 2001 11:44:40 +0228
Date: 2001-08-17T15:43:34+00:00 [thread overview]
Message-ID: <9lje36$ijn$1@houston.jhuapl.edu> (raw)
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
next reply other threads:[~2001-08-17 9:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-17 9:16 Jonathan DeSena [this message]
2001-08-17 16:23 ` Access to tagged type parameters David Brown
2001-08-17 19:26 ` Ted Dennison
2001-08-17 13:55 ` Jonathan DeSena
2001-08-17 21:51 ` Ted Dennison
2001-08-20 14:03 ` Jonathan DeSena
2001-08-17 21:45 ` tmoran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox