comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nickroberts@adaos.worldonline.co.uk>
Subject: Re: List Container Straw Man
Date: Thu, 8 Nov 2001 00:06:15 -0000
Date: 2001-11-08T00:06:15+00:00	[thread overview]
Message-ID: <9scke9$12jb14$4@ID-25716.news.dfncis.de> (raw)
In-Reply-To: u1yjacqea.fsf@gsfc.nasa.gov

"Stephen Leake" <stephen.a.leake.1@gsfc.nasa.gov> wrote in message
news:u1yjacqea.fsf@gsfc.nasa.gov...
> Well, I find this very confusing; there is not enough documentation
> for me.
>
> First, you switched from "Sequence_Reproducer" to "Sequence_Recorder".
> Or maybe you left out a type?

I made a mistake: in the Print_a_List procedure declaration, I used the type
Sequence_Producer when I should have used Terminating_Producer. Sorry.

> Why are there three (or four) independent types?

Each adds one extra level of functionality. This is vitally important.

> How do I write to a
> producer object in the first place, so there is something to read?
> Conversely, how do I read from a recorder?

Remember, an abstract type promises certain operations (and assumed
characteristics). The concrete types derived from it must fulfil those
promised operations (and should fulfil the characteristics), but nothing
stops them adding more operations (and characteristics) of their own!

For example, a list type might be derived from Sequence_Recorder, so that
its contents can be read using Read and End_of_Data, and then re-read using
Restart, and then rewritten using Rewrite and Write. These are the promised
operations that the list type must fulfil, but it could add many others
(insertion, deletion, whatever).

Take another example, a random number generator (RNG). An RNG type might be
derived from Sequence_Producer (the most primitive, non-terminating type).
This means you can read from it using Read, but there is no end to the data
(and no End_of_Data function). 'Read' is the sole promised operation. The
RNG type would doubtless add at least one other operation to allow seeding
of itself.

This is why it is vital to have many types, each adding a small set of extra
'promised' operations.

And because objects (values) of both the list type, the RNG type (or indeed
any other container type conforming to the design) can be passed straight
into any unit which takes one of the abstract iterator types as a parameter,
it means you get the 'write once, use anywhere' effect of good software
engineering.

> > In this way, a piece of software which only needs to iterate over a
> > container can be passed any of the list types, or other container types.
>
> This is true. But it leads to the "complex instantiation" problem that
> is one requirement for the list package under discussion.

Please see my reply to Marin in this thread. I hope it shows that the
instantiations you need (two) are not really all that onerous.

> It also introduces tagged types, which some users might want to avoid
> (they can have run-time overhead, or be hard to test).

I don't think that's true in the great majority of cases. Ada can implement
tagged types very efficiently (because it does not have to deal with
multiple inheritance). I suppose hard data on this will be hard to get.

> Personally, I've never run across a situation where this abstract
> container design really made sense; it was always more important to
> optimize the implentation for real-time issues (I'm a rocket
> scientist, after all :).

I use this scheme all the time. I don't think it's unsuitable for most
real-time software. Many actual container types will be (but that's a
different matter).

> In a truly complete library, I think both options should be available;
> abstract containers and concrete, simple lists. Perhaps the "Dennison
> List" package could be used to implement the doubly-linked list
> variant of the abstract container package; would that work for you?

For the sake of saving one instantiation? Maybe, but I doubt it.

> > Please don't get this elementary aspect of the design wrong!
>
> "Wrong" is too strong. Just because some people give different design
> options different importance does not make them wrong!

You're right, of course, but I get a little frustrated at times, Stephe!

--
Best wishes,
Nick Roberts






  parent reply	other threads:[~2001-11-08  0:06 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
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 [this message]
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