From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,effb80d4bb7716dd X-Google-Attributes: gid103376,public From: Hyman Rosen Subject: Re: Wanted: Ada STL. Reward: Ada's Future Date: 1999/02/05 Message-ID: <36BB5E3C.B9EA5F2C@prolifics.com>#1/1 X-Deja-AN: 441125369 Content-Transfer-Encoding: 7bit References: <790f4q$3l@bgtnsc01.worldnet.att.net> <36B856E4.D921C1D@bton.ac.uk> <36B9E159.C072ECDA@prolifics.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@panix.com X-Trace: news.panix.com 918248994 27204 207.19.14.254 (5 Feb 1999 21:09:54 GMT) Organization: Prolifics Mime-Version: 1.0 NNTP-Posting-Date: 5 Feb 1999 21:09:54 GMT Newsgroups: comp.lang.ada Date: 1999-02-05T21:09:54+00:00 List-Id: Stephen Leake 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 #include #include #include using namespace std; int main() { vector a; copy(istream_iterator(cin), istream_iterator(), back_insert_iterator(a)); } Here, istream_iterator() represents a one-past-the-end iterator of an input stream. The other iterator, istream_iterator(cin), becomes equal to the end one when end-of-file is encountered. The copy algorithm is simply template 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.