comp.lang.ada
 help / color / mirror / Atom feed
From: Hyman Rosen <hymie@prolifics.com>
Subject: Re: Wanted: Ada STL.  Reward: Ada's Future
Date: 1999/02/05
Date: 1999-02-05T21:09:54+00:00	[thread overview]
Message-ID: <36BB5E3C.B9EA5F2C@prolifics.com> (raw)
In-Reply-To: u4sp051dw.fsf@gsfc.nasa.gov

Stephen Leake <Stephen.Leake@gsfc.nasa.gov> writes:
> Ok, that's what I thought. The STL style of expressing ranges as [i,j)
> is an consequence of the implementation, not a requirement of the
> design.

That is not at all what I said. It's a consequence of the desire to
allow arrays to function naturally as STL containers. That makes it
part of the design.

> I don't see why allowing pointers as iterators is a good idea in the
> first place. How do you efficiently maintain the head and tail
> pointers, or other list-wide state, for a doubly linked list when you
> insert from a plain pointer? Apparently you don't!

What in the world are you talking about? Every STL container has an
associated iterator type (two actually, one for constant containers).
STL algorithms operate on iterators, or ranges expressed as a pair of
iterators. The iterator for an array is a plain pointer to array
element, but the iterator into a more complicated container such as a
linked list is certainly not!

> So for an Ada "STL", we can either use [i,j) to be somewhat compatible
> with C++ STL, or we can use [i .. j] to be more Ada-like. I'm not
> clear what the best choice would be, but I lean towards being
> Ada-like. I'd rather woo good Ada programers than ex-C++ programers :).

OK. Just keep in mind that STL allows something like this:

#include <algorithm>
#include <vector>
#include <iterator>
#include <iostream>
using namespace std;
int main()
{
	vector<int> a;

	copy(istream_iterator<int>(cin), istream_iterator<int>(),
	     back_insert_iterator(a));
}

Here, istream_iterator<int>() represents a one-past-the-end iterator of
an input stream. The other iterator, istream_iterator<int>(cin), becomes
equal to the end one when end-of-file is encountered. The copy algorithm
is simply

template <typename In, typename Out>
Out copy(In from, In to, Out where)
{
	while (from != to)
		*where++ = *from++;
	return where;
}

> Again, insisting that a plain pointer can be an iterator is too
> restricting.

As I said, a plain pointer is an iterator of an array. Iterators to
more complicated structures are not plain pointers to element types.




  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 ` Brian Rogoff
1999-02-01  0:00   ` Ehud Lamm
1999-02-02  0:00     ` 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               ` 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-04  0:00               ` Hyman Rosen
1999-02-05  0:00                 ` Stephen Leake
1999-02-05  0:00                   ` Hyman Rosen [this message]
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
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                                     ` robert_dewar
1999-02-09  0:00                                       ` Corey Minyard
1999-02-09  0:00                                     ` dennison
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
     [not found]                     ` <79f24e$t14 <36BB4162.52FC6D9F@averstar.com>
1999-02-05  0:00                       ` dennison
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
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     ` 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           ` William Clodius
1999-02-03  0:00           ` Nick Roberts
1999-02-03  0:00           ` robert_dewar
1999-02-03  0:00             ` Jean-Pierre Rosen
1999-02-03  0:00       ` robert_dewar
1999-02-03  0:00       ` Nick Roberts
1999-02-03  0:00         ` robert_dewar
1999-02-03  0:00           ` Robert A Duff
1999-02-02  0:00     ` Wanted: Ada STL. Reward: Ada's Future Richard D Riehle
1999-02-03  0:00       ` robert_dewar
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 ` Jerry van Dijk
1999-02-01  0:00   ` Marin David Condic
1999-02-01  0:00 ` dennison
1999-02-01  0:00 ` Stanley R. Allen
1999-02-01  0:00 ` Jeff Carter
1999-02-08  0:00   ` Michael F Brenner
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