Top 5
Robert Fraser
fraserofthenight at gmail.com
Fri Oct 10 16:35:22 PDT 2008
Benji Smith wrote:
> 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
Static arrays are needed for C compatibility (in extern(C) structs), so
they're not going anywhere.
More information about the Digitalmars-d
mailing list