Re: Adding functions to generic package



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
.



Relevant Pages

  • Re: Question about OO programming in Ada
    ... package, then you can use that type in the child packages. ... But note that, in Ada, a class is a set of types, whereas in C++ ... There is an alternative unique to the Ada language. ... Lists and Nodes ...
    (comp.lang.ada)
  • Re: How to set up mirrors in Smart Package Manager?
    ... As regards Livna, if you install their livna-release package for FC6, you can ... Mirror lists are a pain, because each mirror has to be entered manually. ... up your channels - it's well worth the effort. ...
    (Fedora)
  • Re: Package Conflicts With Neither Package Installed
    ... Please refer to the Code of conduct for Debian mailing lists: ... Unable to locate package nvidia-glx-new ... The package you are talking about is not even in Debian. ... never heard of dpkg-divert or of diversions before this. ...
    (Debian-User)
  • Re: Mantis package bombs
    ... the time to do this and mailing lists are not a good place to keep ... track of bugs which is why bugzilla exists. ... Not because they are maintainers per se, ... which would explain the state of the Mantis package. ...
    (Fedora)
  • Re: Back Again - RPM using a more efficient database format
    ... XML parsing is also not exactly a light task. ... efficient database scheme. ... rather than a new 2 meg package list for each change to the list. ... I read messages from the public lists. ...
    (Fedora)