Bottom line re GC in D
via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jul 8 02:11:16 PDT 2014
On Tuesday, 8 July 2014 at 03:37:51 UTC, Adrian wrote:
> + Has the GC been dropped?
No, and no matter what exactly will be done, it surely will
always stay at least as an option, and most probably will be
enabled by default.
> + If not, can it be disabled entirely/completely?
>
This is already possible for a long time. Normally it's only
called when the memory allocator runs out of free memory, i.e.
only on allocation, and you can call `GC.disable` to disable it
completely.
For the upcoming release 2.066 (currently in beta), there will be
a function attribute `@nogc` which makes the compiler error out
if a function allocates GC memory (either directly, or by calling
other non- at nogc functions). Parts of the standard library have
already been marked as @nogc, so they can be used inside such
functions, though this is still ongoing work. Other parts have
been changed to avoid allocations, at least where possible. There
are now also some alternatives to functions that return allocated
data to accept a sink delegate instead, so that the caller can
decides whether they want to allocate, and how.
> D has always greatly impressed me, but I need a systems
> language without garbage collection; has D become that now?
Well, yes and no, see above ;-)
I guess more work in this direction will be enabled once we have
`std.allocator`, which Andrei Alexandrescu is working on
currently. There might also be other changes necessary, some kind
of ownership tracking / borrowing for example, to make this safe.
(Manual memory management without help from the language can
easily lead to all kinds of bugs.)
More information about the Digitalmars-d
mailing list