Top 5
Benji Smith
dlanguage at benjismith.net
Fri Oct 10 12:23:28 PDT 2008
Jarrett Billingsley wrote:
> 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."
As long as T[3] and T[5] and T[] are considered different types, I agree
with that sentiment.
But then again, I think array semantics would make a lot more sense if
all arrays were of type T[], regardless of their size, their location
(stack vs heap), and whether they're static or dynamic.
--benji
More information about the Digitalmars-d
mailing list