comp.lang.ada
 help / color / mirror / Atom feed
From: "Peter Hend�n" <phenden@tdab.com>
Subject: Re: (generic) child package of generic package; intantiation of
Date: Tue, 30 Jan 2001 21:33:50 GMT
Date: 2001-01-30T21:33:50+00:00	[thread overview]
Message-ID: <2rGd6.10303$Qb7.1527248@newsb.telia.net> (raw)
In-Reply-To: 3A76F223.B0D07EB7@averstar.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1456 bytes --]

"Tucker Taft" wrote:
> Unfortunately, Mark, Marc, and Pat all forgot to mention that you
> have to "with" the child unit where you plan to instantiate it.
> The way to think about a "with" clause for a child is that it effectively
> inserts the child into the parent.  With a child of a generic,
> inserting the child into the generic parent means that all instances
> of the generic parent now include the generic child nested within
> them.  You can then instantiate one of those nested generics,
> given any instance of the parent.
What I wound up with was (using gnat 3.13p):
--- GenParent.ads
generic
   ...
package GenParent is
   ...
end GenParent;

--- GenParent-GenChild.ads
generic
package GenParent.GenChild is
   ...
end GenParent.GenChild;

--- InstantiatedParent.ads
with GenParent;

package InstantiatedParent is new GenParent(...);

--- InstantiatedParent - InstantiatedChild.ads
with GenParent.GenChild;         -- have to with the generic child package
(1)

package InstantiatedParent.InstantiatedChild is new
InstantiatedParent.GenChild;
----

(1) Is this what you meant?

Is the above the way to do it? Any better ways?

> But the key thing to remember is that the nested generic is only
> made visible where a "with" clause for the generic child applies.

Grateful for any and all help.

Regards,
Peter

--
Peter Hend�n           http://www.algonet.se/~phenden
ICQ: 14672398
Teknisk Dokumentation AB          http://www.tdab.com





  reply	other threads:[~2001-01-30 21:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-29 16:30 (generic) child package of generic package; intantiation of Peter Hend�n
2001-01-29 17:20 ` Marc A. Criley
2001-01-29 17:24 ` mark.biggar
2001-01-29 17:25 ` Pat Rogers
2001-01-29 20:46   ` Peter Hend�n
2001-01-30 16:56     ` Tucker Taft
2001-01-30 21:33       ` Peter Hend�n [this message]
2001-01-30  4:48 ` Jeffrey Carter
2001-01-30 11:53   ` Peter Hend�n
  -- strict thread matches above, loose matches on Subject: below --
2001-01-31  5:34 Christoph Grein
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox