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: Brian Rogoff Subject: Re: Generic units and child units Date: 1999/05/12 Message-ID: #1/1 X-Deja-AN: 477271972 References: <926545009.26110.0.nnrp-04.c2de848f@news.demon.co.uk> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: nntp1.ba.best.com 926565574 215 bpr@206.184.139.136 MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-05-12T00:00:00+00:00 List-Id: On Wed, 12 May 1999, Steve Folly wrote: > Hi, > > I'm having a bit of bother combining generic units and child units... > > Originally I had a List [of integers] package which dynamically added > integers into a List.Object type > using the standard Node with a Previous and Next pointer, dynamically > allocating each node as required. > Fine so far. > > Next, I implemented a List.Iterator child package to enable iteration > through a List.Object > backwards or forwards, starting at the head or tail of the list as required. > Fine again. > > Now, what I really wanted was to make List a generic package so it could > store any type rather than > just integers. OK, that works. > > The problem I have is how to define the (now) generic List.Iterator package. > The only way I > could get it to compile was to include the keyword 'generic' ie. I now > have... > > 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. > begin > ... blah blah > end Test; > > BUT, how do I get access to List.Iterator for the instantiated integer list. > What is the correct syntax? > > Am I even going about this the right way? If possible, I would like to keep > the Iterator child package separate. I'm still wondering the same thing. In similar libraries, I've used child packages as you have used them. -- Brian