What can you "new"

Christopher Wright dhasenan at gmail.com
Mon Mar 23 15:52:26 PDT 2009


Sean Kelly wrote:
> == Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
>> Georg Wrede wrote:
>>> Andrei Alexandrescu wrote:
>>>> Don wrote:
>>>>> Andrei Alexandrescu wrote:
>>>>>> new is a really bad construct. I'm very unhappy that D inherited it.
>>>>> Care to elaborate?
>>>> I just did in the PS :o). New is not uniform: you can't use it easily
>>>> to allocate a pointer to a dynamic array, or even a fixed-size array.
>>>> Why? Because new is syntactically ill-conceived. It also allocates two
>>>> keywords for no good reason.
>>>>
>>>> new should disappear and delete should be an unsafe function.
>>> Have I missed a discussion on what to have instead of new?
>> Nothing.
>> auto a = T(args);
>> should create a T, whether T is a class, array, struct, what have you.
>> This "new" business is lame, lame, lame.
> 
> So it's back to malloc when we want to dynamically allocate a struct,
> or does calling the ctor this way always perform dynamic allocation?

auto a = MyStruct*(); ?



More information about the Digitalmars-d mailing list