-nogc
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Apr 23 11:27:10 PDT 2009
Leandro Lucarella wrote:
> And may I ask what it would happen if I do this with your "-nogc"
> proposal?
>
> class A
> {
> B b;
> }
>
> class B
> {
> A a;
> }
>
> A a = new A;
> a.b = new B;
> a.b.a = a;
>
> ? Wont this leak? Are you planning to make a backup tracing collector to
> fix cycles maybe? Because I don't think using a naive reference counting
> will avoid leaks as easy as you put it...
>
> RC is not *that* simple.
Oh I absolutely agree. In short, what happens depends on how Ref is
implemented. In essence what I suggest is not (a simplified method of)
reference counting, it's a hook that allows various
allocation/collection strategies to be implemented by knowledgeable
people (hint, hint) :o).
I think WeakRef!T would also have to be part of the offering inside
object_whatever.d. Then the example above can be fixed for the
refcounting case by making one of the references weak.
Andrei
More information about the Digitalmars-d
mailing list