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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: container cursor type cannot be tagged Date: Fri, 29 Aug 2014 18:08:36 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <85ppfkxvwg.fsf@stephe-leake.org> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1409353717 22849 69.95.181.76 (29 Aug 2014 23:08:37 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 29 Aug 2014 23:08:37 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:22001 Date: 2014-08-29T18:08:36-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:c8utnmednhss.tg5692sifke0$.dlg@40tude.net... > On Thu, 28 Aug 2014 15:25:59 -0500, Randy Brukardt wrote: > >> If it was me, I'd put a container parameter on every operation (which >> would >> be the prefix), and cursors would work soley like array indexes. > > Huh, remember our discussion about cursor/iterator being a bad idea? No sorry, I don't. But I do know that I was against that model of cursors from the beginning; I just wasn't able to explain why well enough to convince anyone else. > That is another of multiple reasons why. Cursor tend to become a full > class > with descendants and primitive operations which ends up in multiple > dispatch, for whatever reason not available. An index almost always can be > a "final" type which makes everything a lot easier. But please note that iterators are a very different case. They necessarily encapsulate some state and that state is intimately tied to the container -- it doesn't make sense to separate them. Also note that a cursor would always need to include some indication of the container it belongs to, in order that the library can prevent using the cursor with the wrong container. Since these are almost always going to be implemented as wrapped access types, using one with the wrong container would lead to havoc. (And one of the most important properties of the Ada containers is that they never cause more havoc than a bare, fully checked array could.) The problem comes from using the cursor separately from the container, not so much from the fact that cursors know their containers. (The indication does not need to be a pointer in this model, a serial number would be enough, so just because there is an indication doesn't mean that one could use the cursor without the container.) Randy.