If T[new] is the container for T[], then what is the container for T[U]?

Robert Jacques sandford at jhu.edu
Sat Apr 25 11:07:51 PDT 2009


On Sat, 25 Apr 2009 13:30:22 -0400, Unknown W. Brackets  
<unknown at simplemachines.org> wrote:
> What about simply using the const/invariant information?
>
> After all, an "array builder" is a mutable array.  If you don't want to  
> extend it, it should be invariant or const - e.g. invariant(string).

No, immutability really applies to the element and not just the array  
length. Besides, what about "hello" ~ "world"? Essentially, an "array  
builder" is an array with a cheaply, extend-able length and it's often  
used for immutable strings, etc. Also, while a concatenate strings all the  
time I never end up concatenating non-char arrays. And they almost always  
end up being mutable.

> I've always thought the separation of strings and string builders,  
> arrays and array builders, etc. was flawed.  It's just like strcmp;  
> sure, it works, but is it really the right way to compare strings? Can't  
> I just have my == and not worry about it?

Well, you can just use ~= or ~ and not worry about it. Array builders are  
a performance enhancement for one special case at the cost of a general  
performance degradation. (There was a long discussion previously about  
these trade-offs)





More information about the Digitalmars-d mailing list