From: Brian Rogoff <bpr@shell5.ba.best.com>
Subject: Re: Wanted: Ada STL. Reward: Ada's Future
Date: 1999/02/05
Date: 1999-02-05T00:00:00+00:00 [thread overview]
Message-ID: <Pine.BSF.4.05.9902050906310.3807-100000@shell5.ba.best.com> (raw)
In-Reply-To: 36BAEA8B.5B375A30@bton.ac.uk
On Fri, 5 Feb 1999, John English wrote:
> Stephen Leake wrote:
> > I thought Matthew just did that, but you haven't answered the question
> > "why does the STL allow iteration past the end of the array". This
> > bugs me too. Is there a real reason here, or is it an accident of the
> > implementation?
>
> A "past-the-end" value makes it easy to insert items into collections --
> you always insert BEFORE a particular position, so inserting before the
> past-the-end position will append to the end. In the case of arrays you
> can't insert anything, but at least you have read access to arrays in
> exactly the same way as any other collection type. This means that
> non-mutating algorithms (searching, counting, ...) can all be used
> on arrays just as easily as on a linked list. And there's no performance
> penalty either.
>
> > Perhaps it is the most general way to define an iterator that points
> > to nothing? Certainly if the underlying implementation of a collection
> > is an array, this makes sense. But if the underlying implementation is
> > a list, then a null pointer makes more sense. Why not make the
> > abstraction resemble a null pointer, rather than an out-of-bounds
> > index?
>
> But which list is the null pointer pointing to? I did something like
> this in my Ada book (plug, plug :-); there's an iterator for linked
Let me take this opportunity to independently plug John's book. While I
think it is aimed at beginning programmers, there are quite a few very
nice examples, and some nice Ada tricks.
> But anyway: a strength of the STL which seems difficult (impossible?)
> to reproduce in Ada is the ability to treat built-in collection types
> (arrays) in *exactly* the same way as user-defined collection types
> (vectors, maps, etc.).
Exactly true. Anyone seeking to achieve the seamlessness of STL in Ada
will fail. Since you can't overload array indexing or pointer operations
in Ada, *no* pure Ada library will achieve this.
Another strength of C++ is in automatic instantiation of generic
subprograms. This reduces the number of instantiations, and makes code a
lot more readable, IMO, in the same way that overloading properly used
makes code more readable. There really are some nice features of C++, its
just too bad that the language as a whole suffers so much from its C
lineage.
-- Brian
next prev parent reply other threads:[~1999-02-05 0:00 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-01-31 0:00 Wanted: Ada STL. Reward: Ada's Future Alexy V Khrabrov
1999-01-31 0:00 ` Simon Wright
1999-02-01 0:00 ` Jeff Carter
1999-02-08 0:00 ` Michael F Brenner
1999-02-01 0:00 ` Stanley R. Allen
1999-02-01 0:00 ` Jerry van Dijk
1999-02-01 0:00 ` Marin David Condic
1999-02-01 0:00 ` dennison
1999-02-01 0:00 ` Matthew Heaney
1999-02-01 0:00 ` Alexy V Khrabrov
1999-02-01 0:00 ` Matthew Heaney
1999-02-01 0:00 ` Jeff Carter
1999-02-01 0:00 ` Brian Rogoff
1999-02-01 0:00 ` Ehud Lamm
1999-02-02 0:00 ` Pointer Arithmetic (was: Wanted: Ada STL....) adam
1999-02-02 0:00 ` William Clodius
1999-02-03 0:00 ` adam
1999-02-03 0:00 ` robert_dewar
1999-02-03 0:00 ` Jean-Pierre Rosen
1999-02-03 0:00 ` William Clodius
1999-02-03 0:00 ` Nick Roberts
1999-02-03 0:00 ` Nick Roberts
1999-02-03 0:00 ` robert_dewar
1999-02-03 0:00 ` Robert A Duff
1999-02-03 0:00 ` robert_dewar
1999-02-02 0:00 ` Wanted: Ada STL. Reward: Ada's Future Brian Rogoff
1999-02-02 0:00 ` robert_dewar
1999-02-04 0:00 ` Ehud Lamm
1999-02-03 0:00 ` John English
1999-02-03 0:00 ` Matthew Heaney
1999-02-03 0:00 ` Brian Rogoff
1999-02-04 0:00 ` Stephen Leake
1999-02-04 0:00 ` Hyman Rosen
1999-02-05 0:00 ` Stephen Leake
1999-02-05 0:00 ` Hyman Rosen
1999-02-04 0:00 ` Matthew Heaney
1999-02-04 0:00 ` Brian Rogoff
1999-02-05 0:00 ` Stephen Leake
1999-02-05 0:00 ` Brian Rogoff
1999-02-05 0:00 ` John English
1999-02-05 0:00 ` Tucker Taft
1999-02-05 0:00 ` Brian Rogoff
1999-02-05 0:00 ` Richard D Riehle
1999-02-05 0:00 ` Brian Rogoff [this message]
1999-02-06 0:00 ` Matthew Heaney
1999-02-05 0:00 ` John English
1999-02-05 0:00 ` Nick Roberts
1999-02-04 0:00 ` Ehud Lamm
1999-02-04 0:00 ` Brian Rogoff
1999-02-05 0:00 ` Matthew Heaney
1999-02-05 0:00 ` Brian Rogoff
1999-02-08 0:00 ` John English
1999-02-04 0:00 ` Pat Rogers
1999-02-04 0:00 ` Larry Kilgallen
1999-02-04 0:00 ` Pat Rogers
1999-02-04 0:00 ` Larry Kilgallen
1999-02-05 0:00 ` robert_dewar
1999-02-05 0:00 ` Tom Moran
1999-02-05 0:00 ` dewar
1999-02-05 0:00 ` Tom Moran
1999-02-05 0:00 ` dewar
1999-02-05 0:00 ` dennison
1999-02-06 0:00 ` dewar
1999-02-08 0:00 ` dennison
1999-02-08 0:00 ` robert_dewar
1999-02-08 0:00 ` dennison
1999-02-09 0:00 ` robert_dewar
1999-02-09 0:00 ` dennison
1999-02-09 0:00 ` Nick Roberts
1999-02-07 0:00 ` Simon Wright
1999-02-08 0:00 ` Corey Minyard
1999-02-08 0:00 ` Open Source Licensing (was: Wanted: Ada STL. Reward: Ada's Future) dennison
1999-02-08 0:00 ` Corey Minyard
1999-02-09 0:00 ` dennison
1999-02-09 0:00 ` Corey Minyard
1999-02-09 0:00 ` robert_dewar
1999-02-09 0:00 ` Corey Minyard
1999-02-09 0:00 ` Wanted: Ada STL. Reward: Ada's Future robert_dewar
1999-02-09 0:00 ` dennison
1999-02-10 0:00 ` robert_dewar
1999-02-07 0:00 ` Simon Wright
1999-02-05 0:00 ` Larry Kilgallen
[not found] ` <36ba730b.35540068@ <79fmg1$fn0$1@nnrp1.dejanews.com>
1999-02-06 0:00 ` Larry Kilgallen
1999-02-05 0:00 ` robert_dewar
1999-02-05 0:00 ` robert_dewar
1999-02-05 0:00 ` Larry Kilgallen
1999-02-05 0:00 ` robert_dewar
1999-02-05 0:00 ` dennison
1999-02-05 0:00 ` robert_dewar
1999-02-05 0:00 ` dennison
1999-02-06 0:00 ` Nick Roberts
1999-02-05 0:00 ` Tucker Taft
[not found] ` <79f24e$t14 <36BB4162.52FC6D9F@averstar.com>
1999-02-05 0:00 ` dennison
1999-02-05 0:00 ` robert_dewar
1999-02-04 0:00 ` Al Christians
1999-02-05 0:00 ` John English
1999-02-09 0:00 ` micro_ada
1999-02-05 0:00 ` Nick Roberts
1999-02-08 0:00 ` John English
1999-02-02 0:00 ` Richard D Riehle
1999-02-03 0:00 ` robert_dewar
1999-02-05 0:00 ` Corey Minyard
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox