The "no gc" crowd

Jonathan M Davis jmdavisProg at gmx.com
Thu Oct 10 00:46:53 PDT 2013


On Thursday, October 10, 2013 00:30:55 Walter Bright wrote:
> > It doesn't deal with circular references, which people keep bringing up as
> > a very important problem.
> 
> ARC doesn't deal with it automatically, either, it requires the user to
> insert weak pointers at the right places.
> 
> But, if the RefCounted data is actually allocated on the GC heap, an
> eventual GC sweep will delete them.

That may be true, but if you're using RefCounted because you can't afford the 
GC, then using the GC heap with them is not an option, because that could 
trigger a sweep, which is precisely what you're trying to avoid. More normal 
code may be fine with it but not the folks who can't afford the interruption of 
stop the world or any of the other costs that come with the GC. So, if 
RefCounted (or a similar type) is going to be used without the GC, it's going 
to need some type of weak-ref, even if it's just a normal pointer - though as 
you've pointed out, that pretty much throws @safety out the window as no GC is 
involved. But since you've arguably already done that by using malloc instead 
of the GC anyway, I think that it's debatable how much that matters. However, 
the GC would allow for more normal code to not worry about circular references 
with RefCounted.
 
- Jonathan M Davis


More information about the Digitalmars-d mailing list