Future of D 2.x as stable/bug fix, and what's next for D 3.x

bachmeier no at spam.net
Wed Sep 2 14:09:12 UTC 2020

On Wednesday, 2 September 2020 at 09:06:16 UTC, IGotD- wrote:

> Either a language is garbage collected which means the 
> runtime/compiler takes care of the memory management or it has 
> manual memory management. Supporting both is in my opinion not 
> realistic because designing libraries than can work in any 
> environment is too complicated. This is an active choice that 
> the library author must take if automatic memory management 
> should be used or not.

But we program in these mixed environments all the time. Garbage 
collected languages call into C libraries.

Here's how it can work without being complicated, based roughly 
on my experience with other languages: @nogc library functions 
can call only std.nogc and other library functions marked @nogc. 
Any data passed into a @nogc function is protected from being 
garbage collected. You can use the GC to allocate data in @nogc 
functions, but only if it's returned to a call that was made from 
non- at nogc code.

It would require std.nogc but that wouldn't be a monumental task, 
because you don't need to replicate the full functionality of 
Phobos, and big parts are already nogc. You'd just need to insert 
a few restrictions that we already have when doing mixed-language 

More information about the Digitalmars-d mailing list