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-Thread: 103376,81ea1855a67f537a X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.glorb.com!newscon02.news.prodigy.net!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: declaration of an incomplete private type before the private part Date: Fri, 01 Feb 2008 09:00:34 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <5e8bc9cb-a2c1-4c9c-8308-ca8b709801f5@e23g2000prf.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1201874439 10697 192.74.137.71 (1 Feb 2008 14:00:39 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 1 Feb 2008 14:00:39 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:NXYfxK+8oDe0Qud+KZipIFKjr9Y= Xref: g2news1.google.com comp.lang.ada:19676 Date: 2008-02-01T09:00:34-05:00 List-Id: Javi writes: > hi guys, > > I'm very newbye to ADA, so my apologizes in advance. > > My problem: I need to do a declaration such as: > > ----------------------------------------- > ... > type ListNode is private; > type List is private; > > package IterList is new Iterators (Creator => List, > Item => ListNode, > getFirst => Lists.getFirst, > getNext => Lists.getNext, > isLast => Lists.isLast); > > function makeIter (L : List) return IterList.Iterator; > ... > private: > (complete declaration of ListNode and List) > ----------------------------------------- > > > The problem is that I need to complete the type (ListNode and List) > before instancing the new package. But I do not know how to do that! > The only solution I have found is to declare the types non-private and > then give them the complete declaration. Obviously, this solution does > not satisfy me since I want to make the types private. This is a flaw in the design of Ada. You can't instantiate a generic with a private type, in the same package where the private type is declared, and make the instantiation visible to clients (i.e. put it in the visible part). Your solution above (don't make it private) works. Niklas Holsti gave another solution. A third solution is to put the instantiation in a child package, or make it a child itself. Then clients have to "with" both the parent and the child. This won't work if the private part needs to see the instantiation, but it's OK if the body needs to see the instantiation. - Bob