From: tmoran@acm.org
Subject: Re: Access to tagged type parameters
Date: Fri, 17 Aug 2001 21:45:18 GMT
Date: 2001-08-17T21:45:18+00:00 [thread overview]
Message-ID: <Ofgf7.9004$P15.5141814@news1.rdc1.sfba.home.com> (raw)
In-Reply-To: 9lje36$ijn$1@houston.jhuapl.edu
>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.
prev parent reply other threads:[~2001-08-17 21:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-17 9:16 Access to tagged type parameters Jonathan DeSena
2001-08-17 16:23 ` 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 [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox