On 05/27/2010 08:42 PM, Leandro Lucarella wrote:
Andrei Alexandrescu, el 27 de mayo a las 20:06 me escribiste:
On 05/27/2010 06:28 PM, Jonathan M Davis wrote:
I take it that Array is basically supposed to be std.container's version of
C++'s vector or Java's ArrayList? If so, I would suggest that Array is not
the best of names in that it would become very easy to confuse it with
built-in arrays when discussing them (particularly in verbal communication
where you can't see the capital A). Personally, I would have just gone with
Vector, since it's a fairly standard name for that sort of container and
wouldn't be confused with anything else. If you really want Array, that's
fine - it should be clear enough when it's in code - but I would think that
talking about it could easily be confusing enough that it wouldn't be the
best of names.

- Jonathan M Davis

Good point. Other opinions?

I always thought vector was a bad name choice in C++, I had that word
associated with what C++ calls a valarray (a physics vector).

I agree that Array is too generic for D, though, and unfortunately I don't
have a better suggestion, but you asked for other opinions ;)

BTW, what would be the point of an array/vector when you have built-in
arrays? If built-in arrays would be syntax sugar for a real library type,
like AAs, I can see as a good option using Array for that type, since
built-in arrays and the library Array would be the same thing.

This is a good question. The relationship between Array and T[] is simple:

* Array is a compliant container so it is a reference type

* T[] is Array's range

With built-in associative arrays the question becomes even more interesting because the associative array _is_ already a reference type. So Walter and I agreed to make built-in associative arrays just compliant std.container objects, with three differences:

* AssocArray lives in object.di for various reasons

* The compiler translates the type name V[K] as AssocArray!(K, V)

* The compiler translates associative array literals into associative array objects

Other than that... an associative array will be just one of the growing offering of collections in std.container. And I think that's the way it should be.


Andrei

Reply via email to