T[new] misgivings

Rainer Deyke rainerd at eldwood.com
Thu Oct 15 20:54:25 PDT 2009


Andrei Alexandrescu wrote:
> Rainer Deyke wrote:
>> To answer the rephrased question: 'int[new]' should be a value type.
> 
> Well Walter and I agreed they should be pass-by-reference. That doesn't
> mean they must be references, and the fact that the simplest syntax has
> the worst efficiency reminds me of iostreams.

Given that D already has both value types and reference types, the
addition of types that are passed by reference but otherwise act as
value types actually seems reasonable.  It make the language more
orthogonal.

Classes have one set of attributes.  Structs have another.  If the
language absolutely needs to support both sets of attributes, I should
at least be able to mix and match between them.

So, what's the syntax for user-defined value types that are passed by
reference going to be?  ref struct?  opPass?

>> 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.
> 
> My perception is that you're in a minority. Anyway, if there's something
> that T[new] can help with, let us know.

I was under the impression that arrays were generally considered broken,
which is why 'T[new]' is now being introduced.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list