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 X-Google-Thread: 103376,f2690a5e963b61b6 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!news.germany.com!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: GCC 4.0 Ada.Containers Cursor danger. Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1120474891.635131.216700@g44g2000cwa.googlegroups.com> <1120575076.876798.108220@g44g2000cwa.googlegroups.com> <1120583470.429264.325450@g43g2000cwa.googlegroups.com> <42cb8d21$0$22761$9b4e6d93@newsread2.arcor-online.net> Date: Thu, 7 Jul 2005 10:01:02 +0200 Message-ID: NNTP-Posting-Date: 07 Jul 2005 10:00:11 MEST NNTP-Posting-Host: 8d3de7e7.newsread4.arcor-online.net X-Trace: DXC=EJ87jH90eB`ci]h2U0KHce:ejgIfPPlddjW\KbG]kaMhliQbn6H@_Ei?G5hYj:lO>o[6LHn;2LCVn7enW;^6ZC`d<=9bOTW=MNn X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:11923 Date: 2005-07-07T10:00:11+02:00 List-Id: On Wed, 6 Jul 2005 18:07:38 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:ldco4pwrxop4$.1py0a7isiagea.dlg@40tude.net... > ... >> "All of the containers specify positions using a cursor, >> which is similar to an access type in that it designates an element." >> >> So? Is it position or access? > > We don't say, on purpose. Its is not either, it has elements of both. It > doesn't matter anyway. That's the point. In my view a decision about which checks are appropriate must follow from the semantics of the thing. Especially the case of mutable containers shows the problem. Depending on whether cursors are bound to a container's location, an element at some specific location, the element at a location, one or another implementation requirement should follow. >>It is not clear to me what the semantics a cursor has. Is it a location in the container? >>Then that should be an index or position. > > It's not a location, and it wouldn't make sense for it to be one (other than > for a Vector). A linked list position, for instance, would require a O(N) > walk through the list. Yuck. But it definitely refers to a location. Otherwise iteration using cursor would be impossible. So it is to define what precisely happens when the location it refers disappear. Or when the element it refers goes to another location etc. So far it seems that the *implied* semantics is sort of "the element at the location". Which is obviously incompatible with many operations on mutable containers. >> Is it a pointer to an individual element? Then that should be an access type object. > > No. A raw access type could never be checked, while a Cursor can (and IMHO, > should) be checked for problems. Ditto >> Cursor looks like an amorphous mixture inheriting disadvantages of both. > > We don't say exactly what it is in part because it is different for the > different containers. But you still can use the same abstraction on any > container. The problem with cursors is that they are quite difficult to get right for mutable containers. I tend to believe that cursor is a wrong abstraction there. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de