From: Brian Rogoff <bpr@shellx.best.com>
Subject: Re: Ada Generic Library (very) preliminary release
Date: 1997/07/13
Date: 1997-07-13T00:00:00+00:00 [thread overview]
Message-ID: <Pine.SGI.3.95.970713193310.25027A-100000@shellx.best.com> (raw)
In-Reply-To: mheaney-ya023680001307971311450001@news.ni.net
On Sun, 13 Jul 1997, Matthew Heaney wrote:
> In article <Pine.SGI.3.95.970713094409.22907C-100000@shellx.best.com>,
> Brian Rogoff <bpr@shellx.best.com> 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
next prev parent reply other threads:[~1997-07-13 0:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-07-08 0:00 Ada Generic Library (very) preliminary release Brian Rogoff
1997-07-09 0:00 ` Mats Weber
1997-07-09 0:00 ` Brian Rogoff
1997-07-13 0:00 ` Matthew Heaney
1997-07-13 0:00 ` Brian Rogoff
1997-07-13 0:00 ` Matthew Heaney
1997-07-13 0:00 ` Brian Rogoff [this message]
1997-07-14 0:00 ` Jon S Anthony
1997-07-14 0:00 ` Brian Rogoff
1997-07-14 0:00 ` Jon S Anthony
1997-07-09 0:00 ` Richard Kenner
1997-07-09 0:00 ` Brian Rogoff
1997-07-09 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox