From: Tucker Taft <stt@averstar.com>
Subject: Re: Calling generic children from their parent?
Date: 1999/06/24
Date: 1999-06-24T00:00:00+00:00 [thread overview]
Message-ID: <37723E5B.53577638@averstar.com> (raw)
In-Reply-To: 7krps5$ldb$1@nnrp1.deja.com
rcollinson@my-deja.com wrote:
> ...
> My problem is that I TRY to instantiate a generic
> child unit inside the body of the parent and it
> will not compile. The text Rendezvous with Ada 95
> states this is possible on page 337 but I have
> been unable to make it work. (On a slightly
> different subject, why in the example on page 337
> do they WITH and ELABORATE Generic_Parent.Child in
> the last exerpt?)
If you can post a small self-contained example with the
accompanying error message you received from the compiler,
I suspect someone could quickly point out the solution to your problem.
Here is an example that should work:
generic
package P is
procedure Dummy;
end P;
generic
package P.C is
type T is null record;
end P.C;
with P.C;
package body P is
package Child is new P.C;
type NT is new Child.T;
procedure Dummy is
X : NT;
begin
null;
end;
-- ...
end P;
Note that you normally have to instantiate all ancestors
of a child of a generic before instantiating the child.
However, when inside the parent generic, the name of the
parent generic itself represents the "current instance",
and hence you don't need to instantiate the parent generic inside
itself to be able to instantiate the child.
> Roger
--
-Tucker Taft stt@averstar.com http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.) Burlington, MA USA
next prev parent reply other threads:[~1999-06-24 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-06-23 0:00 Calling generic children from their parent? RCollinson
1999-06-23 0:00 ` Dale Stanbrough
1999-06-23 0:00 ` rcollinson
1999-06-24 0:00 ` Tucker Taft [this message]
1999-06-24 0:00 ` rcollinson
1999-06-25 0:00 ` Tucker Taft
1999-07-01 0:00 ` rcollinson
1999-06-23 0:00 ` Matthew Heaney
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox