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,6c424a2d310d290 X-Google-Attributes: gid103376,public From: Brian Rogoff Subject: Re: Ada Generic Library (very) preliminary release Date: 1997/07/13 Message-ID: #1/1 X-Deja-AN: 256745736 References: <33C39534.E8DAC63D@elca-matrix.ch> Newsgroups: comp.lang.ada Date: 1997-07-13T00:00:00+00:00 List-Id: On Sun, 13 Jul 1997, Matthew Heaney wrote: > In article , > Brian Rogoff wrote: > >(The high priority > >is finding a better way around the interleaving omission I mention above, > >since it forces too much to be public, as Mats Weber pointed out. I know > >this, but I am uncertain as to what to do. One solution might be to just > >break up the iterator child package into two or more, and use with clauses > >to "order" the elaboration of the children). Which does not work for generic children. > I haven't seen the library, but if you want some parts public and some > private, you have to do it this way in Ada 95: > > ... stuff deleted ... No, what I want is something different, the problem is related to freezing and when I can instantiate generics. In the AGL, I use generic formal package parameters to plug algorithms to iterators (cursors) and in order to make the library comfortable I instantiate all of the "signatures" (null bodied generic packages which act like interfaces) that an Iterator_Type supports in the Iterators package (which is a child package of the generic container). The problem is that I can't instantiate those signature packages in the spec unless everything it needs is public, which is rather blecherous (for Ada). So a typical Iterators child package looks like this: generic package AGL.Some_Container.Iterators is type Iterator_Type is ... public type declaration, ugly ... ... Start(), Finish(), Increment(), etc ... ... other package decls ... package Bidirectional_Iterators is new AGL.Bidirectional_Iterators(Value_Type, Value_Ref_Type, Iterator_Type, Increment, Decrement, Get_Value, Set_Value, Get_Pointer, "=" ); ... etc ... and that Iterator_Type declaration has to be public for me to have that Bidirectional_Iterators instantiation. What I'd like is something like (pseudo Ada ahead) generic package AGL.Deques.Iterators is type Iterator_Type is private; private type Iterator_Type is ... full declaration here ... end private -- Illegal Ada ... stuff ... package Input_Iterators is new AGL.Input_Iterators( Value_Type, Iterator_Type, Increment, Get_Value ); ... more stuff ... private ... another private section ... end private ... more stuff ... end AGL.Deques.Iterators; Of course, that would fix my problem, but I believe that some other issues in Ada (the withing problem) require other fixes, so it is probably best to get many examples of things that are hard to do now, get workarounds, and see how heinous the results are before proposing a sweeping language change. Maybe a radical new view of packages is needed for the next Ada? For now, I'd settle for a tolerable workaround. Separating the child package into two parts doesn't help, because there seems to be no way for a child of a generic parent to use types from a sibling. It is clear that the STL, or a "generic library" like it can be implemented in Ada 95 (the RPI paper shows that nicely, and I highly recommend it) but I'd like to get the most elegant implementation I can, with visibility suitably restricted. > What are you trying to do, exactly, that can't be done as is shown above? I hope I've been clearer. -- Brian