eliminate new operator paraphernalia

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Feb 14 10:17:44 PST 2010


Currently new is baroque to the extreme. Should we eliminate the 
class-specific allocators in favor of a simple scheme for placement new? 
All that's really needed is to construct an object of a given type at a 
given address. All of the syntactic mess around it is unnecessary.

I think class-specific new and delete are not a useful feature.

Second, the whole new anonymous class thing is for Java's sake. Do you 
think we need to keep all that?

I suggest the following syntaxes for a type T, an integral length, an 
initializerlist a la "e1, e2, e3, ..." that could be empty, and an addr 
convertible to void*:

new T[length]
new T(initializerlist)
new(addr) T[length]
new(addr) T(initializerlist)

and call it a day.

What do you think?


Andrei



More information about the Digitalmars-d mailing list