T[new] misgivings
Rainer Deyke
rainerd at eldwood.com
Thu Oct 15 20:10:43 PDT 2009
Andrei Alexandrescu wrote:
> int[new] a;
> ....
> a = [1, 2, 3];
>
> What should that do?
This question can be rephrased as, "should 'int[new]' be a reference
type or a value type (or something else)?"
If 'int[new]' is a reference type, then it must rebind, because that's
what assignment does for reference types. If 'int[new]' is a value
type, then it must modify the array in place, because that's all it can
do. If 'int[new]' is neither a reference type nor a value type, then
we're back to (some of) the problems with slices.
To answer the rephrased question: 'int[new]' should be a value type.
> W: Nobody complained about it with slices.
FWIW, I found arrays in D1 so completely broken that I didn't it worth
the effort to complain about every little detail. Everything about them
was wrong. I consider them a textbook example of what not to do.
--
Rainer Deyke - rainerd at eldwood.com
More information about the Digitalmars-d
mailing list