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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,842accb6a7d76669 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-04 13:00:30 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!colt.net!newspeer.clara.net!news.clara.net!btnet-peer!btnet!news-hub.cableinet.net!blueyonder!proxad.net!feeder2-1.proxad.net!news2-2.free.fr!not-for-mail Message-ID: <3BE5AB8F.681577D0@free.fr> Date: Sun, 04 Nov 2001 21:56:47 +0100 From: Jean-Marc Bourguet X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.10 i586) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: List container strawman 1.1 References: <3BE301D1.4010106@telepath.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Organization: Guest of ProXad - France NNTP-Posting-Date: 04 Nov 2001 22:00:29 MET NNTP-Posting-Host: 212.27.55.231 X-Trace: 1004907629 news2-2.free.fr 15117 212.27.55.231 X-Complaints-To: abuse@proxad.net Xref: archiver1.google.com comp.lang.ada:15772 Date: 2001-11-04T22:00:29+01:00 List-Id: Ted Dennison wrote: > > I have a new version of the strawman up at my website at > http://www.telepath.com/dennison/Ted/Containers-Lists-Unbounded.ads.html > . This version has the cascading style sheet too, so hopefully nearly > everyone should be able to read it. First, what's the semantic of assignation and of the equality test ? [...] > type Iterator is private; > Done_Iterating : constant Iterator; > > function First (Subject : List) return Iterator; > function Last (Subject : List) return Iterator; > function Next (Location : Iterator) return Iterator; > function Previous (Location : Iterator) return Iterator; > function Item (Location : Iterator) return Element; > > -- Ideally these routines would verify that Location was issued for > the Subject > -- list and is still valid, but that would be tough to enforce. > Better to call > -- such misuse a "bounded error", or somesuch. [...] (I assume that the first test was meaningfull in the previous version). It is not hard: the list can have a list of iterators and mark some invalid when deleting an element or when going out of existance. Then using an invalid iterator would raise an exception (Next, Previous could be make to work). Having a Is_Valid function testing the validity of the iterator could be nice. A procedure to set the item as well as to get it could also be nice. I wonder why you choose testing the equality with a special value to mark the end of iteration instead of having a "done" function. (If you mimicked the C++ STL, there it is so so that "algorithms" works also with normal pointers using pointer arithmetic, as in Ada we don't use pointer arithmetic that's not an argument). The one iteraror way has the following advantages : - only one iterator to pass around, - easier to have "iterators" generating an infinite amount of data - easier to have filtering iterators. While with the two iterators scheme, it is: - easier to describe ranges Both schemas have the same expressing power but having worked with both, I prefer the one iterator one. -- Jean-Marc