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!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.109.56.219.65.mobile.3.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: Ada.Containers and concurrent modification exception. Date: Wed, 19 Sep 2018 17:22:51 +0200 Organization: JSA Research & Innovation Message-ID: <87musdtstw.fsf@jacob-sparre.dk> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: franka.jacob-sparre.dk; posting-host="109.56.219.65.mobile.3.dk:109.56.219.65"; logging-data="14030"; mail-complaints-to="news@jacob-sparre.dk" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:JHlTYCbbP2H87D8vDvh0pQEWAoc= Xref: reader02.eternal-september.org comp.lang.ada:54371 Date: 2018-09-19T17:22:51+02:00 List-Id: rakusu_klein@fastmail.jp writes: > Why Ada's Cursors does not provide the > ConcurrentModificationException, as Java Collections do, Because that is something from Java. ;-) > or some variant of it? The Ada containers define the concept of tampering. I can't remember which exception you get in case you tamper with a standard container, but you can be pretty sure you will get one. > Consider the following: > > with Ada.Containers.Indefinite_Ordered_Maps; > ... > The_Map : Map; > ... > declare > I : Cursor := First (The_Map); > J : Cursor := First (The_Map); > begin > -- Now Cursors are synchronized with each other and with a container. > Delete (The_Map, I); > -- It's O'k. But now J lost a sync and points to a dead Node. > Next (J); > -- What should I expected here, > -- any well defined exception or > -- raising a zombie? > end; Did you try it? Both with GCC 6.3.0 and with GNAT CE 2018 I get System.Assertions.Assert_Failure, but that is definitely not defined as a part of the tampering checks, so I suspect GNAT is wrong (but still safe) here. I've posted an executable example here: https://bitbucket.org/sparre/ada-2012-examples/src/default/src/container_tampering.adb (Randy, feel free to adapt it for ACATS, if it shows something relevant) Greetings, Jacob -- "In case of discrepancy, you must ignore what they ask for and give what they need, ignore what they would like and tell them what they don't want to hear but need to know." -- E.W. Dijkstra