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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,4d972ac0c79198a5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-16 12:25:20 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Generic child units Date: 16 May 2003 15:24:17 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: <3ec12f93$1@epflnews.epfl.ch> <3ec1f6ab$1@epflnews.epfl.ch> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: skates.gsfc.nasa.gov 1053113996 16368 128.183.235.92 (16 May 2003 19:39:56 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 16 May 2003 19:39:56 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:37405 Date: 2003-05-16T19:39:56+00:00 List-Id: Robert A Duff writes: > Rodrigo Garc�a writes: > > > Stephen Leake wrote: > > > with Parent.Child; > > > procedure Foo is > > > package Par is new Parent (Elem => Integer); > > > package Chi is new Par.Child; > > > begin > > > ... > > > end Foo; > > > Note that the second instantiation is "Par.Child", not "Parent.Child". > > > > Thanks, that is one of the things I was doing wrong. > > > > >>within the declarative region of the parent package (as required by > > >>RM 10.1(18))? > > > There is no RM 10.1 (18), at least in the copy I have (came with > > > GNAT). And I don't understand the rest of the sentence, either. So I > > > don't know what you mean here. > > > > Sorry, I meant RM 10.1.1 (18) as David C. Hoos has remarked. I still > > do not understand that requirement. > > Paragraph 19.b in the AARM explains it. You are instantiating the child > *outside* the parent generic, so you want to instantiate the child of > the instance of the parent, not the child of the parent. Make sense? > > Here's the AARM text: > > 18 A child of a parent generic package shall be instantiated or renamed > only within the declarative region of the parent generic. But in my code above, Chi is an instantiation of "a child of a parent generic package", and it is _not_ "within the declarative region of the parent generic". > 19 For each declaration or renaming of a generic unit as a child of > some parent generic package, there is a corresponding declaration > nested immediately within each instance of the parent. [This > declaration is visible only within the scope of a with_clause that > mentions the child generic unit.] > > 19.a Implementation Note: Within the child, like anything > nested in a generic unit, one can make up-level references to > the current instance of its parent, and thereby gain access to > the formal parameters of the parent, to the types declared in > the parent, etc. This ``nesting'' model applies even within the > generic_formal_part of the child, as it does for a generic > child of a nongeneric unit. > > 19.b Ramification: Suppose P is a generic library package, and > P.C is a generic child of P. P.C can be instantiated inside the > declarative region of P. Outside P, P.C can be mentioned only > in a with_clause. Conceptually, an instance I of P is a package > that has a nested generic unit called I.C. I see. So I actually instantiated Par.Child (as the code actually says :), which is _not_ a "child of a generic parent", even though I think of it that way. That makes sense. As is sometimes the case, the ARM is not immediately clear to us non-lawyers. > Mentioning P.C in a with_clause allows I.C to be instantiated. > I need not be a library unit, and the instantiation of I.C need > not be a library unit. If I is a library unit, and an instance > of I.C is a child of I, then this instance has to be called > something other than C. > > - Bob -- -- Stephe