comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nickroberts@adaos.worldonline.co.uk>
Subject: Re: List Container Straw Man
Date: Wed, 7 Nov 2001 23:58:31 -0000
Date: 2001-11-07T23:58:31+00:00	[thread overview]
Message-ID: <9scke8$12jb14$3@ID-25716.news.dfncis.de> (raw)
In-Reply-To: 9sc5l8$9b7$1@nh.pace.co.uk

I probably haven't explained it well, but I think you may be getting hold of
the wrong end of the stick a little.

In general, according my suggested design, you would need two instantiations
to start making use of a utility container. The first would instantiate the
package (called Iteration let us say) of abstract types:

   package Widget_Iteration is new Iteration(Aerial_Widget);

The second would instantiate the package declaring the utility container,
using the first package - a 'signature' package - as its generic parameter:

   package Widget_Storage is new
Linear_Linked_List_Storage(Widget_Iteration);

You might then want to use a 'use', or more likely a subtype declaration to
give the widget container type a convenient name:

   subtype Widget_Store is Widget_Storage.Store_Type;

and then you can start using it:

   Nuts, Bolts: Widget_Store; -- initialised empty

To recap, the great advantage of this design is that Widget_Store is now a
general-purpose iterator type (derived from
Widget_Iteration.Reproducable_Sequence probably), and so any unit that takes
a widget iterator type can have Widget_Stores passed into it with no further
ado. A generic procedure:

   generic
      package Specific_Iteration is new Iteration(<>);
   procedure Print_a_List (List: in out
Specific_Iteration.Terminating_Sequence'Class);

   procedure Print_a_List (List: in out
Specific_Iteration.Terminating_Sequence'Class) is
      Item: Specific_Iteration.Element_Type;
   begin
      while not End_of_Data(List) loop -- dispatching
         Read(List,Item); -- dispatching
         Put_Line(Item);
      end loop;
   end;

can be used to print out the items in any container of any type (that
conforms to my design):

   procedure Print_Widgets is new Print_a_List(Widget_Iteration);

   ...

   Print_Widgets(Nuts);
   Print_Widgets(Bolts);

Phew! I hope this clarifies things. It's really not too difficult in actual
usage, is it? In big software, it would save a huge amount of effort, and
Ada is an industrial language.

--
Best wishes,
Nick Roberts






  reply	other threads:[~2001-11-07 23:58 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-06 16:45 List Container Straw Man Nick Roberts
2001-11-06 17:29 ` Stephen Leake
2001-11-06 18:25   ` Marin David Condic
2001-11-06 23:02     ` Nick Roberts
2001-11-07 19:49       ` Stephen Leake
2001-11-07 20:30         ` Marin David Condic
2001-11-07 23:58           ` Nick Roberts [this message]
2001-11-08  4:34             ` Jeffrey Carter
2001-11-08 10:45             ` Ehud Lamm
2001-11-08 19:09               ` Nick Roberts
2001-11-09 16:32                 ` Ted Dennison
2001-11-10  2:20                   ` Nick Roberts
2001-11-10 19:50                     ` Ehud Lamm
2001-11-11  3:48                       ` Nick Roberts
2001-11-08 10:41           ` Ehud Lamm
2001-11-08 19:20             ` Marin David Condic
2001-11-08 20:35               ` Ehud Lamm
2001-11-09 16:39             ` Ted Dennison
2001-11-08  0:06         ` Nick Roberts
2001-11-09 16:16           ` Stephen Leake
2001-11-09 16:24             ` Ehud Lamm
2001-11-09 16:52               ` Brian Rogoff
2001-11-09 18:04             ` Darren New
2001-11-09 20:05               ` Stephen Leake
2001-11-10  3:24             ` Nick Roberts
2001-11-06 23:52   ` Nick Roberts
2001-11-07  4:44     ` A question and a request Eric Merritt
2001-11-07 11:00       ` Preben Randhol
2001-11-07 12:54         ` David C. Hoos, Sr.
2001-11-08  2:35           ` dale
2001-11-07 13:24         ` Eric Merritt
2001-11-07 13:58       ` James Rogers
2001-11-07 16:32       ` Jeffrey Carter
2001-11-09 23:32       ` Matthew Heaney
replies disabled

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