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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,404e254cbd5f6d08 X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: Generic units and child units Date: 1999/05/13 Message-ID: #1/1 X-Deja-AN: 477415558 Sender: bobduff@world.std.com (Robert A Duff) References: <926545009.26110.0.nnrp-04.c2de848f@news.demon.co.uk> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1999-05-13T00:00:00+00:00 List-Id: Brian Rogoff writes: > > generic > > type Item is private; > > package List is > > ... blah blah > > end List; > > > > generic > > package List.Iterator is > > ... blah blah > > end List.Iterator; > > That's right, all children of a generic package must be generic. > > > > > > In my test program I can instantiate a List for integers: > > > > with List; > > procedure Test is > > package Integer_List is new List (Item => Integer); > > package Integer_List_Iterator is new Integer_List.Iterator; > > is the correct syntax. Right, but don't forget to say "with List.Iterator;". When you instantiate List to create Integer_List, it's as if you were instantiating the whole hierarchy of children, except that the children of Integer_List are not visible unless the corresponding children of List are with'ed. That is, "with List.Iterator;" causes Integer_List.Iterator to be visible, so you can then instantiate it. This is all sort of theoretical -- in practise, the compiler will typically just instantiate the children it needs to; it typically doesn't even know about the whole hierarchy, because new children can be added later. See RM-10.1.1 and 8.3(20). - Bob -- Change robert to bob to get my real email address. Sorry.