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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: A few questions Date: Wed, 18 Nov 2015 10:53:49 +0100 Organization: cbb software GmbH Message-ID: References: <5007b311-5d2e-448c-b8c8-fc2e2d88ea5e@googlegroups.com> <8hw612c7lfik.1cy0uanjjnpzv$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: TWQ9mg4k1m/sph/eQ+zHLA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:28440 Date: 2015-11-18T10:53:49+01:00 List-Id: On Tue, 17 Nov 2015 15:30:28 -0600, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:8hw612c7lfik.1cy0uanjjnpzv$.dlg@40tude.net... >> On Mon, 16 Nov 2015 13:13:05 -0600, Randy Brukardt wrote: >> >>> You're speaking nonsense. The element is part of the container, and the >>> only way to access it is from the container. >> >> I think you are confusing indices with iterators. The very concept of the >> iterator is accessing elements without the container as opposed to the >> index. > > That's surely not my idea of an iterator. And it doesn't work for Ada in any > case, as that would allow altering elements of constant containers (we > prevent that in the containers library by requiring an "in out" container > parameter in all cases where modifications are allowed). Access /= Update. Compare it with "access constant T" The difference between index and iterator is that accessing through the index requires the container. An index is always relative to some container. The iterator does not need the container, the container is implicit. >> Both concepts of >> iterator and index have fundamental operations to create a new instance >> referencing some other element (next, previous, sibling, parent, neighbour >> etc) > > The C++ containers mix up the ideas of iterators and cursors (they're > essentially the same thing there). By your description, you want them to be > the same -- but in that case, just use the cursors and be done with it. You > will sacrifice safety and ease-of-use to do so, but whatever. That is not my point. It is that Index + 1 is another index and that Iterator.Next is another iterator. From the interface point of view you don't need the container to get another instance of either. And regarding safety, it is very important that you don't need the container when accessing elements or advancing the iterator. Well-designed iterators meant to keep the iteration state *inside* the iterator object rather than in the container, for evident reasons. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de