Why does D rely on a GC?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 19 07:13:45 PDT 2014


On 8/19/14, 12:25 AM, ketmar via Digitalmars-d wrote:
> On Tue, 19 Aug 2014 07:14:17 +0000
> ponce via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
>
>> I work in such an environment and I tend to agree with you.
> just replace GC with stub doing only allocs (or use GC.disable) and
> manage resource freeing manually (or with corresponding templated
> struct wrappers).

One issue with this is e.g. hashtables have no primitive for freeing 
entries.

>> In D having deterministic resource release is harder because
>> scoped ownership is less polished than in C++.
> but why?! see 'scoped' to scope allocations. and, for example, 'File',
> which is refcounted internally. plus 'scope()' finalizers.
>
> i'm pretty sure that scoped ownership in D at least on par with C++, if
> not better and simplier either to write, to read and to use.
>
> of course, you'll loose such nice features as closures and slices, but
> hey, C++ doesn't have them too! ok, C++11 has lambdas, and i don't know
> if D lambdas can work without GC and don't leak.

They don't use GC if scoped.

Andrei



More information about the Digitalmars-d mailing list