From: ytomino <aghia05@gmail.com>
Subject: Re: Two approaches of iterators for the key-value pairs
Date: Sun, 29 Nov 2015 09:55:42 -0800 (PST)
Date: 2015-11-29T09:55:42-08:00 [thread overview]
Message-ID: <922dda2c-13c3-4fea-ae98-ff3c1718fca4@googlegroups.com> (raw)
In-Reply-To: <f822f37e-a1ab-4c6e-9e5f-0eb5e286e528@googlegroups.com>
> > > 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.
prev parent reply other threads:[~2015-11-29 17:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-27 15:25 Two approaches of iterators for the key-value pairs ytomino
2015-11-27 16:30 ` Dmitry A. Kazakov
2015-11-27 18:08 ` ytomino
2015-11-27 20:50 ` Dmitry A. Kazakov
2015-11-27 22:52 ` bj.mooremr
2015-11-27 17:00 ` Pascal Obry
2015-11-27 18:25 ` ytomino
2015-11-27 17:43 ` Brad Moore
2015-11-27 19:38 ` ytomino
2015-11-27 19:46 ` ytomino
2015-11-27 23:11 ` Brad Moore
2015-11-28 8:58 ` Simon Wright
2015-11-28 19:54 ` Brad Moore
2015-11-28 23:34 ` Simon Wright
2015-11-29 21:17 ` Bob Duff
2015-11-29 16:17 ` Simon Wright
2015-11-29 17:55 ` ytomino [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