The demise of T[new]

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Oct 19 10:34:04 PDT 2009


Denis Koroskin wrote:
> On Mon, 19 Oct 2009 20:16:50 +0400, Andrei Alexandrescu 
> <SeeWebsiteForEmail at erdani.org> wrote:
> 
>> I thought I explained that above and in several other posts. I have 
>> the feeling this is going in circles, but let me add one more thing. 
>> People would want to have a reasonable way of choosing between T[new] 
>> and T[]. The differences between them are subtle (I have two tables 
>> showing the primitives of T[] and T[new], which are very similar). 
>> That static decision concerns future appends to the array, which 
>> doesn't strike me as something you know from the get-go through future 
>> iterations of a design. Use of "auto" messes up things further: a nice 
>> function may choose to return T[new] because it just created an array 
>> (an implementation detail), but clients may find that unexpected.
>>
>>
> 
> Put it simple: T[] is a range, and T[new] is a container. They belong to 
> different leagues.

Define ranges and define containers.

> Yes, there is a lot common between them, because T[] supports some 
> subset of operations that T[new] support.

No. You see, even you who have a close perspective on the issue have 
gotten confused. T[new] does not support assignment from range. So T[] 
and T[new] are not in a subtyping relationship. They support subtly 
different primitives.

> We are going in circles because you couldn't convince anyone that we 
> don't need dynamic array type in language core. Not unless library types 
> are usable in CTFE (and have nice syntax).

"Anyone" is a bit assuming I think.


Andrei



More information about the Digitalmars-d mailing list