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: a07f3367d7,8e11100f675ea2df X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.66.80.41 with SMTP id o9mr10758051pax.4.1357927965496; Fri, 11 Jan 2013 10:12:45 -0800 (PST) Path: 6ni101701pbd.1!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.news.ucla.edu!news.snarked.org!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: asynchronous task communication Date: Tue, 8 Jan 2013 21:29:15 +0100 Organization: cbb software GmbH Message-ID: <142z4tyl4xqrq.1cr8vdvx44cvx.dlg@40tude.net> References: <1c2dnd5E6PMDR33NnZ2dnUVZ_sednZ2d@earthlink.com> <7NednS4s2oukfXzNnZ2dnUVZ_oadnZ2d@earthlink.com> <7cudnYloBfQDw3_NnZ2dnUVZ_rKdnZ2d@earthlink.com> <6bqdndEYjoxeGHnNnZ2dnUVZ_sadnZ2d@earthlink.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: cDN0fd8KlIeJLyErIrSf0A.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2013-01-08T21:29:15+01:00 List-Id: On Tue, 08 Jan 2013 18:18:44 +0000, Simon Wright wrote: > Jeffrey Carter writes: > >> On 01/08/2013 05:02 AM, Brian Drummond wrote: > >>> So, holding onto a cursor would be unsafe (i.e. no longer refer to the >>> original object) after an "insert" operation, possibly earlier in the >>> vector? >> >> If you have an item in your (unbounded) array, indexed by Positive, at >> index 3, it will still be at index 3 if you assign to components at >> other indices, or extend the array by adding new components beyond the >> current end of the array. However, if you insert a new component >> before the existing item at index 3, then all the components after the >> new component will shift up, and the existing item will then be at >> index 4. >> >> This should be pretty obvious if you think about how you would >> implement an unbounded array. >> >> One would think that a Cursor would behave similarly. > > Not so! The Cursor becomes ambiguous[1], and using it is a bounded > error. GNAT GPL 2012 implements Cursor using an Index, & behaves the way > you'd expect. > > [1] http://www.ada-auth.org/standards/12rm/html/RM-A-18-2.html#p240 Yep, cursor is a bad abstraction, with the semantics sometimes ill-defined. Pointers fall into same category. On the contrary, index is a good abstraction for all ordered containers like arrays are. The semantics of index is well defined for all operations on the container. For a graph or a tree, vector is an inappropriate interface because edges are usually enumerated in a different manner than vector does. So, if vectors should be used then rather privately. And if nodes of the graph need to be referenced then cursors or indices should again be used only privately. Usually graphs require some reference counting schema when nodes are accessed with read and read-write accesses differentiated when graph should be updated. Furthermore read-write access may require cloning of nodes on demand preserving consistency of other views etc. It is not a simple issue, highly dependant on the problem space. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de