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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f89c9977a6e4ceda X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-13 12:17:40 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Missing in Booch: range operations Date: 13 Nov 2002 12:17:39 -0800 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0211131217.1a300d32@posting.google.com> References: <3dcb8eec$0$307$bed64819@news.gradwell.net> <1ec946d1.0211081307.24a6c05c@posting.google.com> NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1037218660 11949 127.0.0.1 (13 Nov 2002 20:17:40 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 13 Nov 2002 20:17:40 GMT Xref: archiver1.google.com comp.lang.ada:30832 Date: 2002-11-13T20:17:40+00:00 List-Id: Simon Wright wrote in message news:... > mheaney@on2.com (Matthew Heaney) writes: > > > The problem is that iterators only know about elements -- they don't > > know anything about containers. Neither Charles nor the STL attempts > > to detect this error. > > Matt, you say this as though it were a law of nature! There is nothing > in the notion of iterator that prevents them knowing about the > container. Indeed (being pedantic) the very name iterator indicates > that there is a container involved (otherwise, what would you be > iterating over?) When I speak of an iterator, I am refering to what STL and Charles do. In that model, iterators don't know about containers. Charles iterators are modelled on iteration thru a linked list, for example: List : List_Type; declare Node : Node_Access := List.Head; begin while Node /= null loop Node := Node.Next; end loop; end; In other words, the "iterator" Node_Access doesn't know anything about the list object. It only knows about the nodes in the list (and nodes in the list don't know anything about the list, either). Of course, it is possible to implement an iterator type as a "fat" pointer, comprising a pointer to the internal node, and another pointer to the container. But this is not necessary in order to have a working iterator, and it does incur a space penalty. Charles has been optimized for flexibility and efficiency, and it is general enough that such a layer (comprising a "fat" iterator) on top of the existing infrastructure can be implemented quite easily. As much as possible I prefer to defer issues as this ("thin" vs. "fat" iterators) to the library user.