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 10.182.79.70 with SMTP id h6mr56101306obx.22.1448819742650; Sun, 29 Nov 2015 09:55:42 -0800 (PST) X-Received: by 10.182.120.101 with SMTP id lb5mr25383obb.7.1448819742627; Sun, 29 Nov 2015 09:55:42 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!mv3no5658017igc.0!news-out.google.com!l1ni436igd.0!nntp.google.com!mv3no7227401igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 29 Nov 2015 09:55:42 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=153.181.129.1; posting-account=Mi71UQoAAACnFhXo1NVxPlurinchtkIj NNTP-Posting-Host: 153.181.129.1 References: <0c524381-442a-49cc-9d72-27a654320153@googlegroups.com> <073bed9a-32f2-4045-93ec-064322edf883@googlegroups.com> <834c6afa-870e-4921-a1f1-4fe2b061811a@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <922dda2c-13c3-4fea-ae98-ff3c1718fca4@googlegroups.com> Subject: Re: Two approaches of iterators for the key-value pairs From: ytomino Injection-Date: Sun, 29 Nov 2015 17:55:42 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:28591 Date: 2015-11-29T09:55:42-08:00 List-Id: > > > Both choices could be made to have the same interface for the user, with the only difference being whether "in" or "of" appears in the loop. > > > > Yes. > > (And, Hashed_Maps/Ordered_Maps already use "in". So I felt "in" is suitable.) > > Not sure what you mean here. Hashed_Maps/Ordered_Maps also already uses "of", > you can use either today, so how is one more suitable than the other? > I think the "of" form involves less clutter that that user has to write, so I would generally try to use that, unless you really need a Cursor somewhere in the loop. Well, Hashed_Maps/Ordered_Maps don't have a pair type similar to Name_Value_Pair_Type. for E of The_Map_Object loop This E is Element_Type. We can not get the key of it with "of". In this case, the indexing function accepting Cursor is Element or Reference, and it returns Element_Type. On the other hand, in AI: for Pair of Ada.Environment_Variables.All_Variables loop This Pair is Name_Value_Pair_Type. The indexing function accepting Cursor is Current_Variable, and it returns not String but Name_Value_Pair_Type. I think this difference prevents us from writing a generic subprogram for common use. Sorry that the explanation of mine was lacking. By the way, the indexing function of std::map of C++ STL returns a pair. I have been pointed out it by one C++ user.