* Glueing using Generic Units
@ 2003-05-04 21:30 Fingertip
0 siblings, 0 replies; only message in thread
From: Fingertip @ 2003-05-04 21:30 UTC (permalink / raw)
Hey everyone!
I'm interested in creating a generic package that is really flexible. What
I mean is that instead of importing another package using a 'with' clause,
which binds me to a certain interface of the 'with'ed unit, I want to glue
the units together with a generic interface.
(As far as I know, this is a known and acceptable technique)
For example, my package requires a hash table and search tree, so I create
these two interface packages:
generic
type hash_item_type is private;
with procedure add...
with procedure find...
-- et cetra
package hash_interface is
end hash_interface;
<the same thing goes for tree_interface>
Now I can create a generic implementaion of my package, independant of any
special implementation of the two data structures:
generic
with package Hash is new hash_interface (<>);
with package Tree is new tree_interface (<>);
package My_Package is
-- <Here comes my spec>
end My_Package;
Now comes my question:
In this definition set, the two generic package parameters are disjoint.
That is, I gave no restriction on their parameters.
However, sometimes I'd want to restrict the generic parameters a little
bit, for example, demand that Hash and Tree will store the same data type.
This kind of thing should look like:
generic
type item_type is private;
with package Hash is new hash_interface (hash_item_type => item_type);
with package Tree is new tree_interface (tree_item_type => item_type);
package ...
But, of course, this declaration is incomplete, since if I already started
supplying generic parameters, I have to specify them all, which is
unwanted.
So, my question (finally!) is:
Is it possible to do what I want, or am I trying the wrong thing in Ada?
Thanks in advance,
Fingertip
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-05-04 21:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-04 21:30 Glueing using Generic Units Fingertip
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox