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, T_FILL_THIS_FORM_SHORT autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a6b:1647:: with SMTP id 68-v6mr28633151iow.65.1537381473070; Wed, 19 Sep 2018 11:24:33 -0700 (PDT) X-Received: by 2002:aca:5349:: with SMTP id h70-v6mr147788oib.4.1537381472843; Wed, 19 Sep 2018 11:24:32 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.166.215.MISMATCH!x188-v6no141544ite.0!news-out.google.com!c63-v6ni139ith.0!nntp.google.com!x188-v6no141538ite.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 19 Sep 2018 11:24:32 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=176.59.51.65; posting-account=-CxkpgoAAAC4sQudwZebWnArsZbT2lvS NNTP-Posting-Host: 176.59.51.65 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <64f5bbad-2f06-4ea9-aa33-8c66e9cbb2a5@googlegroups.com> Subject: Re: Ada.Containers and concurrent modification exception. From: rakusu_klein@fastmail.jp Injection-Date: Wed, 19 Sep 2018 18:24:33 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:54380 Date: 2018-09-19T11:24:32-07:00 List-Id: =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 19 =D1=81=D0=B5=D0=BD=D1=82=D1=8F=D0=B1=D1= =80=D1=8F 2018 =D0=B3., 18:53:31 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE= =D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Simon Wright =D0=BD=D0=B0=D0=BF=D0=B8= =D1=81=D0=B0=D0=BB: > It would be a good thing if the error was detected. Perhaps submit a bug > report to AdaCore? I am new in Ada, so don't know what is it =E2=80=94 a bug or a feature. Honestly, I just try to implement a standard containers in Ada by myself fo= r educational purposes. In process I looking in GNU Classpath sources for a= n advice, and notice, that they are used an int counters (an int in Java ha= ve wrap-around semantic) in both containers and iterators for preventing wo= rking with invalid iterators. They call this a =E2=80=9Cfail-fast semantic= =E2=80=9D. So I decided to implement my own containers in that way, for exa= mple: private type State_Type is mod 2 ** Integer'Size; type Map is record State : State_Type :=3D State_Type'First; Size : Natural :=3D Natural'First; Root : Node_Access :=3D new Node_Object (Variant =3D> Empty); end record; type Map_Access is access constant Map; type Cursor is record Container : Map_Access :=3D null; State : State_Type :=3D State_Type'First; Node : Node_Access :=3D null; end record; In operations with container I just compare States in Container and Cursor = and throw a Concurent_Modification exception if they are not equal. If any = operation deletes a Node, I just increment States in Container and Cursor= , if it used, =E2=80=94 it makes invalid any other Cursors. It may be stupi= d, but works well for me. After all I looked at the Ada.Containers and notice, that its Cursors does = not have any kind of modification counters. So I decided to ask here about = it.