Top 5

Jarrett Billingsley jarrett.billingsley at gmail.com
Fri Oct 10 11:05:53 PDT 2008


On Fri, Oct 10, 2008 at 11:54 AM, Benji Smith <dlanguage at benjismith.net> wrote:

>> new T[x] is a brain-dead syntax that I wish Walter hadn't imported in the
>> first place.
>
> Really? I think it's very valuable.
>
> The "new T[x]" syntax lets you construct an array as an RValue. Without that
> syntax, you have to declare an array before using it.

No, what he's getting at is that "new T[x]" does not mean "allocate a
statically-sized array", it means "allocate a dynamically-sized
array".  "new T" for any T should mean "allocate a T", not "allocate
something that's kind of close to a T."

What Andrei is implying, then is that for dynamic arrays, we should
have to use the (already-legal) "new T[](n)" form, and "new T[x]"
would mean to allocate a statically-sized array on the heap.



More information about the Digitalmars-d mailing list