On Monday, 7 January 2013 at 21:49:12 UTC, Phil Lavoie wrote:
Or the global one he uses?
Both actually, iirc. delete foo; is discouraged in favor of a
library function destroy(foo) (or something, the name has changed
once), and the class allocators can be done at the creation site
(std.typecons has functions like emplace or Scoped) or with
static methods and private constructors.
Personally, I would like the delete operator to continue to
exist, just to explicitly delete objects when needed (although
scope objects works fine in most cases).
Bah, I'd like to get rid of both new and delete, replacing both
with simple library functions. Well, probably not "get rid of"
because that'd break too much code, but certainly discourage in
favor of library function templates.
A benefit there is you could swap out to other things without
changing the syntax, and it can return special library types.
import gc;
auto foo = New!Foo(); // could return a NotNull!Foo, which is
substitutable for plain Foo, but also gives the guarantee that it
isn't null
or
import malloc;
auto foo = New!Foo(); // could return RefCounted!Foo or whatever
Another benefit with all library is it'd clear up the delete
deprecation... since new is just a library function, there'd be
no confusion about delete being a library function either :)