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=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a05:620a:661:: with SMTP id a1mr36948634qkh.408.1579230529793; Thu, 16 Jan 2020 19:08:49 -0800 (PST) X-Received: by 2002:aca:5303:: with SMTP id h3mr1814373oib.109.1579230529249; Thu, 16 Jan 2020 19:08:49 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!feeder5.feed.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!g89no4814310qtd.0!news-out.google.com!w29ni1433qtc.0!nntp.google.com!g89no4814299qtd.0!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 16 Jan 2020 19:08:48 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=50.66.161.135; posting-account=lzqe5AoAAADHhp_gregSufVhvwu22fBS NNTP-Posting-Host: 50.66.161.135 References: <3c6f1486-293d-4eb5-a379-279b108248d8@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Tally From: Brad Moore Injection-Date: Fri, 17 Jan 2020 03:08:49 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:57857 Date: 2020-01-16T19:08:48-08:00 List-Id: On Wednesday, January 15, 2020 at 2:03:14 AM UTC-7, Simon Wright wrote: >=20 > and then of course >=20 > for C in Counts.Iterate loop > Put_Line (Count_Maps.Key (C)'Image > & " -> " > & Count_Maps.Element (C)'Image); > end loop; This is interesting, in AI12-0189-1/07 (Loop body as anonymous procedure), = there is an example given in the AI showing how the feature could be used to similarly iterate through a map container. for (C : Cursor) of My_Map.Iterate loop Put_Line (My_Key_Type'Image (Key (C)) & " =3D> " & My_Element_Type'Image (Element (C))); end loop; -- The above is equivalent to: declare procedure P (C : Cursor) is begin Put_Line (My_Key_Type'Image (Key (c)) & " =3D> " & My_Element_Type'Image (Element (C))); end P; begin My_Map.Iterator (P'Access); end; Here is another example where new Ada 2020 machinery is used to do somethin= g, which ends up looking more complicated than doing it the gool ol' Ada 20= 12 way ;-). The only real difference is that "(C: Cursor)" is replacing "C"= , and its an "of" loop, rather than an "in" loop. While the example is illustrative, I think a better example is needed at le= ast,=20 as we shouldn't be showing an example if it is ultimately not the recommend= ed way to tackle the problem. I would recommend Simon's loop over this. Brad