From: Jere <jhb.chat@gmail.com>
Subject: Re: Non-standard functions in GNAT's Ada.Containers packages?
Date: Fri, 16 Sep 2022 08:47:03 -0700 (PDT) [thread overview]
Message-ID: <36c9b75d-2d3b-4882-894d-21c44d8a383fn@googlegroups.com> (raw)
In-Reply-To: <6a8a1468-5148-49d7-b342-327f8eaf8097n@googlegroups.com>
On Thursday, September 15, 2022 at 1:11:19 PM UTC-4, amado...@gmail.com wrote:
> Thanks, Niklas.
>
> > ... There are functions First and Next ... procedure Iterate ...
>
> Too verbose and error-prone (forget the Next and you get an endless loop).
> > "for X of M loop ... end loop".
> Not possible for maps.
I'm not sure I understand. I tried it in gnat 11 and it compiled just fine:
*************************************************
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Containers.Ordered_Maps;
procedure Program is
package Maps is new Ada.Containers.Ordered_Maps(Integer,Integer);
Map : Maps.Map;
begin
Map.Insert(1,10);
Map.Insert(2,20);
Map.Insert(3,30);
Map.Insert(4,40);
for Element of Map loop
Put_Line(Element'Image);
end loop;
end Program;
*************************************************
Output:
10
20
30
40
*************************************************
Even tried it on some online compilers and it compiled and ran:
IDEONE online compiler: https://ideone.com/H2oEZt
If this isn't what you mean, what is the missing feature.? the "for of" version does work for maps as far as I can tell.
prev parent reply other threads:[~2022-09-16 15:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 12:36 Non-standard functions in GNAT's Ada.Containers packages? G.B.
2022-09-14 16:04 ` Egil H H
2022-09-15 7:13 ` G.B.
2022-09-15 14:26 ` Marius Amado-Alves
2022-09-15 15:03 ` Niklas Holsti
2022-09-15 17:11 ` Marius Amado-Alves
2022-09-15 17:22 ` Dmitry A. Kazakov
2022-09-16 16:03 ` Marius Amado-Alves
2022-09-16 16:30 ` Marius Amado-Alves
2022-09-16 17:08 ` Jere
2022-09-16 11:33 ` Björn Lundin
2022-09-16 15:00 ` Marius Amado-Alves
2022-09-16 15:42 ` Egil H H
2022-09-16 18:53 ` Björn Lundin
2022-09-16 15:47 ` Jere [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