Revamping associative arrays

Bill Baxter wbaxter at gmail.com
Mon Oct 19 14:18:31 PDT 2009


On Mon, Oct 19, 2009 at 1:58 PM, KennyTM~ <kennytm at gmail.com> wrote:
> On Oct 20, 09 03:40, Piotrek wrote:
>>
>> Bill Baxter pisze:
>>>>>
>>>>> Just get rid of the the one-argument foreach over AAs altogether and
>>>>> force
>>>>> the user to be
>>>>> explicit about it.
>>>>
>>>> I wouldn't do so. Would anybody do an error by thinking that foreach
>>>> (elem,table) should iterate over keys?
>>>
>>> Bearophile. And anyone coming from python, at the least. And anyone
>>> who agrees with the logic of connecting 'in' with what gets iterated.
>>>
>>
>> And only python that I am aware of. Java,C#,PHP (which hold most of all
>> programmers) are defaulting to values unless explicitly stated.
>>
>
> and Javascript. and Objective-C.

I took a look at C# yesterday, and I don't think it is true there.
As far as I can tell IDictionary is the closest thing to AA in C#, and
for it default iteration yields Key,Value pairs called
DictionaryEntry.  MSDN Says: "Since each element of the IDictionary
object is a key/value pair, the element type is not the type of the
key or the type of the value. Instead, the element type is
DictionaryEntry."

So C# avoids the ambiguity.

Unless there's some other AA type in C#.

--bb



More information about the Digitalmars-d mailing list