OSNews article about C++09 degenerates into C++ vs. D discussion

Benji Smith dlanguage at benjismith.net
Mon Nov 20 09:18:06 PST 2006


Miles wrote:
> But looking at the problem, being someone from algorithms, I think it is
> possible and feasible to implement array slicing using malloc
> allocation. An extra field will be needed anyway since you need
> reference count for the array, just put it along with the beginning of
> the array and only a single pointer will be needed for both reference
> count and beginning of array.
> 
> Cyclic references is a problem only when using GC. If the programmer
> wants to use a malloc-based allocation, he knows he should handle cyclic
> references himself. Not a problem.

Both of these comments indicate an assumption that the GC will be using 
a reference count anyhow, so you may as well explicitly manage a 
reference count where necessary.

But that's not the case for D's GC. It doesn't use reference counts at 
all. If I remember correctly, the D garbage collector uses a 
mark-and-sweep collector. These kinds of collectors are generally more 
performant and more deterministic than reference-counting collectors. 
And they have no problem with cycling references.

--benji



More information about the Digitalmars-d mailing list