T[new] misgivings

Fawzi Mohamed fmohamed at mac.com
Fri Oct 16 05:14:27 PDT 2009


On 2009-10-16 11:49:12 +0200, Walter Bright <newshound1 at digitalmars.com> said:

> Don wrote:
>> There are two sensible options:
> 
> I see the question as, is T[new] a value type or a reference type? I 
> see it as a reference type, and so assignment should act like a 
> reference assignment, not a value assignment.

I also see T[new] as a reference type.
Unfortunately this precludes some optimizations like putting size and 
capacity directly at the start of the allocated array, avoiding a 
redirection to access data: The caller object would miss the changes if 
the block is reallocated.

T[new] a;
T[new] b;
b.length=LongLength;
a.length=?

But as putting them at the start of the array might have an adverse 
effect on optimizations that expect special alignment (vector 
operations) maybe not everything is bad.

Fawzi




More information about the Digitalmars-d mailing list