Re: Adding functions to generic package
- From: Matthew Heaney <matthewjheaney@xxxxxxxxxxxxx>
- Date: Sat, 28 May 2005 16:27:46 GMT
Preben Randhol <randhol+cla@xxxxxxx> writes:
> I'm using the charles library which has a generic list package. I
> would like to add two procedures Randomise and Move so that all my
> lists can use them. I cannot modify the library itself, so what
> choices do I have? Is making a child package the only way to add the
> procedures in a generic way?
If you want to take advantage of the representation of the list
container type, then you would have to create a child. Otherwise, if
your algorithm can be implemented in terms of the already-existing
(primitive) operations of the type, then it doesn't have to be a child.
You could do something like:
with Charles.Lists.Double.Unbounded;
generic
with package P is new Charles.Lists.Double.Unbounded (<>);
use P;
package Generic_List_Ops is
procedure Randomize (Container : in out Container_Type);
procedure Move (...);
end;
If these are truly generic algorithms, then you could implement them as,
well, generic algorithms, and then either use those as is, or use them
to implement the generic package above.
What do Randomize and Move do? If you have a tentative implementation,
then post it (or just mail it to me) and we can figure what is the best
option for you.
-Matt
.
- Follow-Ups:
- Re: Adding functions to generic package
- From: Preben Randhol
- Re: Adding functions to generic package
- References:
- Adding functions to generic package
- From: Preben Randhol
- Adding functions to generic package
- Prev by Date: GtkAda & OpenGl on linux
- Next by Date: Re: Adding functions to generic package
- Previous by thread: Adding functions to generic package
- Next by thread: Re: Adding functions to generic package
- Index(es):
Relevant Pages
|