D on next-gen consoles and for game development

Jonathan M Davis jmdavisProg at gmx.com
Thu May 23 16:02:00 PDT 2013


On Thursday, May 23, 2013 22:02:05 QAston wrote:
> I think that Phobos should have some support for manual memory
> management. I don't mean clearing out the gc usage there, as it's
> fairly obvious. I rather think about something like
> unique_ptr/shared_ptr in the std. I think unique_ptr can't be
> implemented without rval refs, also C++ sollutions may not fit
> here. Anyways, now it's not so straightforward how to live
> without gc so standard sollution would be really helpful.

We have std.typecons.RefCounted, which is basically a shared pointer.

> Also, it should be visible in C++/D that D can really deal with
> manual memory management conveniently - when I checked out Dlang
> first time I felt very disappointed that "delete" operator is
> deprecated. "So - they advertise one can code without GC, yet
> they seem to deprecate the operator" - false claims discourage
> people from using new languages.

delete is only used for GC memory, and manual memory management should really 
be done with malloc and free rather than explicitly freeing GC memory. But if 
you really want to risk blowing your foot off, you can always use destroy to 
destroy an object in GC memory and core.memory.GC.free to free it.

Also, once we get custom allocators, it should be easier to manually manage 
memory (e.g. I would assume that it would properly abstract doing malloc and 
then emplacing the object in that memory so that you do something like 
allocator!MyObject(args) rather than having to deal with emplace directly).

- Jonathan M Davis


More information about the Digitalmars-d mailing list