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-Thread: 103376,55f6e230b02eff2f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news.germany.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Containers - nontrivial element access Date: Wed, 03 Oct 2007 01:16:10 +0200 Message-ID: <5mg1prFdasfqU1@mid.individual.net> References: <1191275759.184463.238350@n39g2000hsh.googlegroups.com> <5mdfipFcv1dsU1@mid.individual.net> <1191343257.343180.80480@y42g2000hsy.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: individual.net 6dJJ1lHWIX4KrAolbTYlYAyWAkqI2JAzDNqadexBNug7Hj1ik= Cancel-Lock: sha1:k89byxazele62og3aevWq/+0C1A= User-Agent: KNode/0.10.5 Xref: g2news2.google.com comp.lang.ada:2257 Date: 2007-10-03T01:16:10+02:00 List-Id: Matthew Heaney wrote: > On Oct 1, 7:52 pm, "Alex R. Mosteo" wrote: >> >> I don't think that's reproducible as-is with the standard containers. It >> must be more verbose. There's no way to get a reference to the element in >> the Ada containers (unless you want to go the 'Unrestricted_Access way >> inside Update_Element, but that would require anyway extending the >> standard containers), so you can have dangling cursors but no dangling >> pointers. > > If this is a vector, you can use index values. Yep, I was just talking in general. In any case one has to go to some lengths to get dangling cursors; in typical usage this has *very very* rarely happened to me. > > >> There was a recent thread (started by myself) on the amount of copying >> involved in the use of the containers. Someone said that returning >> accesses was deemed too unsafe and thus dropped, IIRC. I have not a >> strong position on if dangling cursors is a great improvement over >> dangling accesses, given what we gain/lose; in my experience a dangling >> cursor has been always as bad as a dangling pointer, in the sense that >> the program was erroneous beyond recovery; admittedly I have never got a >> memory violation using the containers so post-hoc diagnostics are >> quicker. > > If you're using GNAT, then compile the container instantiations with - > gnata, and the container will detect dangling cursors. Try it! Ummm, perhaps I'm confused. IIRC, the dangling cursor is detected once you try to use it, not if the container goes out of scope or the element is removed by other means than that cursor. Is this what you mean? I'm not trying to imply otherwise.