If T[new] is the container for T[], then what is the container for T[U]?
Steven Schveighoffer
schveiguy at yahoo.com
Mon Apr 27 05:06:54 PDT 2009
On Sat, 25 Apr 2009 12:56:15 -0400, Unknown W. Brackets
<unknown at simplemachines.org> wrote:
> Well, a range of an associative array is a possibility (not a slice, but
> e.g. from std.algorithm.)
>
> I think it'd be a mistake to discount that. Being able to treat
> associative arrays like arrays, in some cases (e.g. with count(), etc.)
> is nice. That said, i don't even know that std.algorithm currently
> supports this.
Sure, but why should a range type of an AA be a special builtin type? It
makes sense with array slices because they are valuable to use in many
different ways, can be useful as sub-ranges, and keep their value long
after the array has been changed. An AA range would be useful only for
iterating over all the elements. Once the AA changes, the AA range is
invalid. Making a subrange is pretty much useless, since there's no real
order to the data. When a range is necessarily the range of the entire
container, it becomes a trivial addition to the typesystem just to meet
interface requirements. Array slices are way more useful than that.
I'd say A[U] is the container type, and AARange!(A, U) is the range if you
wish to have a type name. I see no reason to add a builtin type to deal
with AA ranges.
-Steve
More information about the Digitalmars-d
mailing list