Assigning a static array

Steven Schveighoffer schveiguy at yahoo.com
Fri Apr 19 06:59:18 PDT 2013


On Thu, 18 Apr 2013 18:13:14 -0400, Ali Çehreli <acehreli at yahoo.com> wrote:


> Interesting.
>
> Personally, I would not even bother with the second one and expect the  
> caller to simply put square brackets around the arguments:

[snip]

>
> It is now safe, right?

Yes, for this case it is OK.  But I want a consistent interface in
dcollections.  Other containers do not use arrays as storage, so the
bracketed version for something like a TreeSet would be a complete waste
(and in fact, only the variadic version exists there).  The special case
for ArrayList is the slice version, where it actually takes on that slice
as its internal storage.  ArrayList is meant to bridge the gap between D
slices and dcollections.  It's range type is a D slice as well.

-Steve


More information about the Digitalmars-d-learn mailing list