From: Brad Moore <bmoore.ada@gmail.com>
Subject: Re: Tally
Date: Thu, 16 Jan 2020 19:08:48 -0800 (PST)
Date: 2020-01-16T19:08:48-08:00 [thread overview]
Message-ID: <e29e8773-1834-402a-a339-85decd044feb@googlegroups.com> (raw)
In-Reply-To: <lyo8v5ytv3.fsf@pushface.org>
On Wednesday, January 15, 2020 at 2:03:14 AM UTC-7, Simon Wright wrote:
>
> and then of course
>
> 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)) & " => " &
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)) & " => " &
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 something, which ends up looking more complicated than doing it the gool ol' Ada 2012 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 least,
as we shouldn't be showing an example if it is ultimately not the recommended way to tackle the problem. I would recommend Simon's loop over this.
Brad
prev parent reply other threads:[~2020-01-17 3:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-14 15:27 Tally Gilbert Gosseyn
2020-01-14 16:22 ` Tally Niklas Holsti
2020-01-14 17:28 ` Tally Simon Wright
2020-01-15 11:52 ` Tally Simon Wright
2020-01-14 21:08 ` Tally Jeffrey R. Carter
2020-01-15 3:40 ` Tally Brad Moore
2020-01-15 9:03 ` Tally Simon Wright
2020-01-15 23:09 ` Tally Jere
2020-01-16 11:34 ` Tally Simon Wright
2020-01-16 15:35 ` Tally Brad Moore
2020-01-16 20:20 ` Tally Randy Brukardt
2020-01-16 22:03 ` Tally Jeffrey R. Carter
2020-01-16 22:00 ` Tally Jeffrey R. Carter
2020-01-16 22:25 ` Tally Simon Wright
2020-01-17 2:51 ` Tally Brad Moore
2020-01-17 3:08 ` Brad Moore [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox