From: Fingertip <kammar@deletethispart.actcom.co.il>
Subject: Glueing using Generic Units
Date: Sun, 04 May 2003 21:30:17 GMT
Date: 2003-05-04T21:30:17+00:00 [thread overview]
Message-ID: <newscache$g2tdeh$3bh$1@lnews.actcom.co.il> (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
reply other threads:[~2003-05-04 21:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox