The demise of T[new]

Fawzi Mohamed fmohamed at mac.com
Mon Oct 19 13:06:10 PDT 2009


On 2009-10-19 19:34:04 +0200, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> Denis Koroskin wrote:
>> 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.

unless I miss something
a_new[]=slice;
works just as
a[]=slice;

as in any case you have a slice on the left

a=slice; // should redefine the slice

and yes that is (correctly) not supported by T[new]

a=range;
should not be used in general imho because a slice should be a valid 
range, and I don't want similar operations to have very different 
results (changing the data or just changing the slice object itself).

Fawzi




More information about the Digitalmars-d mailing list