Revamping associative arrays

Sergey Gromov snake.scaly at gmail.com
Sun Oct 18 08:45:24 PDT 2009


Sun, 18 Oct 2009 06:18:34 -0400, bearophile wrote:

>> Then I couldn't understand why the hell iterating on collection
>> returns a key in the first place. It's so not intuitive.<
> 
> What's intuitive on iterating on values? Well, I think Walter agrees
> with you, I remember his explanation (iterating on a normal array
> doesn't yield its indexes), but beside what's intuitive you have also
> to keep in mind what's handy, and iterating on keys is more useful.

It's easy to see what's intuitive if you consider what a collection
contains.  To me, it contains *values*, always.  These values may be
indexed: by an arbitrary key (AA), by an integral index (array), or not
at all (single-linked list).  But the index is not the point, it's only
a way to access values.  And when I iterate over a collection, I
definitely wan to iterate over the values it contains, regardless of an
indexing scheme this particular collection uses.



More information about the Digitalmars-d mailing list