comp.lang.ada
 help / color / mirror / Atom feed
* Combining packages
@ 2001-10-31 18:15 Preben Randhol
  2001-10-31 18:31 ` Matthew Heaney
  0 siblings, 1 reply; 5+ messages in thread
From: Preben Randhol @ 2001-10-31 18:15 UTC (permalink / raw)


Hi

I have made a generic package called Double_Linked_List. I have also a
package called Wordgroups which has the type Wordgroup and several
functions/procedures connected with the type.

Now I want to have a List of Wordgroups. 

First I made a child package Wordgroups.List of the Wordgroups pacakge
like this:

with Double_Linked_List;
with Wordgroups;

   package Wordgroups.List is
         new Double_Linked_List (Data_Type => Wordgroups.Wordgroup_Type);


Now I relized that it would be nice to have a procedure like:

   procedure Add (List        : in out  List_Type;
                  Word        : in      String;
                  Explanation : in      String) is

      Wordgroup : Wordgroup_Type;

   begin
      Create (Wordgroup, Word, Explanation);
      Append_Element (List, Wordgroup);
   end Add;

so that I don't have to do:

   Create (Wordgroup, Word, Explanation);
   Append_Element (List, Wordgroup);

in the rest of the program, only Add.

But I cannot add this to Wordgroups.List.

I would appreciate some hints on how to do something like this. Thanks
in advance.

Preben Randhol
-- 
�.., chaos is found in greatest abundance wherever order is being
sought. It always defeats order, because it is better organized.�
                            -- Interesting Times, Terry Pratchett



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Combining packages
  2001-10-31 18:15 Combining packages Preben Randhol
@ 2001-10-31 18:31 ` Matthew Heaney
  2001-10-31 20:27   ` Preben Randhol
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Heaney @ 2001-10-31 18:31 UTC (permalink / raw)



"Preben Randhol" <randhol+abuse@pvv.org> wrote in message
news:slrn9u0jr0.5nn.randhol+abuse@kiuk0156.chembio.ntnu.no...
> But I cannot add this to Wordgroups.List.

If you mean you can't make Add a child of Wordgroups.List, that's true.  But
what's wrong with simply making Add a child of Wordgroups?







^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Combining packages
  2001-10-31 18:31 ` Matthew Heaney
@ 2001-10-31 20:27   ` Preben Randhol
  2001-10-31 20:41     ` Matthew Heaney
  0 siblings, 1 reply; 5+ messages in thread
From: Preben Randhol @ 2001-10-31 20:27 UTC (permalink / raw)


On Wed, 31 Oct 2001 13:31:47 -0500, Matthew Heaney wrote:
> 
> "Preben Randhol" <randhol+abuse@pvv.org> wrote in message
> news:slrn9u0jr0.5nn.randhol+abuse@kiuk0156.chembio.ntnu.no...
>> But I cannot add this to Wordgroups.List.
> 
> If you mean you can't make Add a child of Wordgroups.List, that's true.  But
> what's wrong with simply making Add a child of Wordgroups?

you mean put the Add procedure in another child package?

Preben



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Combining packages
  2001-10-31 20:41     ` Matthew Heaney
@ 2001-10-31 20:40       ` Preben Randhol
  0 siblings, 0 replies; 5+ messages in thread
From: Preben Randhol @ 2001-10-31 20:40 UTC (permalink / raw)


On Wed, 31 Oct 2001 15:41:13 -0500, Matthew Heaney wrote:
> 
> "Preben Randhol" <randhol+abuse@pvv.org> wrote in message
> news:slrn9u0rij.du.randhol+abuse@kiuk0156.chembio.ntnu.no...
>> you mean put the Add procedure in another child package?
> 
> No.  I mean make the procedure itself a child:
> 
> procedure Workgroups.Add (...);
> 
> Child units can be packages or subprograms, and they can be either public or
> private.  In fact, creating a child subprogram is the intended way to extend
> an abstraction without having to resort to inheritance.

Ah. Thanks. Didn't know you could do that.

Preben
-- 
Please, stop bombing civilians in Afghanistan. One cannot write off
killing innocent children and other civilians as "collateral damage".
A civilian is a civilian whether he or she is American or from another
country in the world.           http://web.amnesty.org/11september.htm



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Combining packages
  2001-10-31 20:27   ` Preben Randhol
@ 2001-10-31 20:41     ` Matthew Heaney
  2001-10-31 20:40       ` Preben Randhol
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Heaney @ 2001-10-31 20:41 UTC (permalink / raw)



"Preben Randhol" <randhol+abuse@pvv.org> wrote in message
news:slrn9u0rij.du.randhol+abuse@kiuk0156.chembio.ntnu.no...
> you mean put the Add procedure in another child package?

No.  I mean make the procedure itself a child:

procedure Workgroups.Add (...);

Child units can be packages or subprograms, and they can be either public or
private.  In fact, creating a child subprogram is the intended way to extend
an abstraction without having to resort to inheritance.








^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-10-31 20:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-31 18:15 Combining packages Preben Randhol
2001-10-31 18:31 ` Matthew Heaney
2001-10-31 20:27   ` Preben Randhol
2001-10-31 20:41     ` Matthew Heaney
2001-10-31 20:40       ` Preben Randhol

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox