> Circular references will cause the object to stay around indefinitely

I was thinking of the reference counting as being totally seperate from gc.
So ref counting would have no effect one way or the other as to how long
objects "stay around".  The only effect of the ref counting would be to call
the special method which is not the gc finalizer.  I don't have a name for
this method yet, maybe "pre-finalizer"?

> any object that holds a reference to a reference-counted object must
itself be reference-counted

I don't see why.  Is this another instance where you are thinking of the ref
counting being part of gc?

----- Original Message -----
From: "Paul Brannan" <pbrannan / atdesk.com>
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Monday, November 26, 2001 7:10 AM
Subject: [ruby-talk:26518] Re: [OT] Re: KDE or GNOME curiosity question...


> > How hard would it be to have an option to use reference counting in a
> > particular class?  This class would be handled normally by the garbage
> > collector, but instances of this class would have a method called
> > immediately when the last reference is gone (before the finalizer).
>
> I've been wondering the same thing.  A few of problems with reference
> counting:
>
>   1) Circular references will cause the object to stay around
indefinitely.
>   2) If the object is referenced from an anonymous function, it will stay
>      around indefinitely (or, at least, until the anonymous function is
>      garbage-collected, in which case you have suddenly turned your
>      reference counting GC into a mark/sweep GC).
>   3) More generally, any object that holds a reference to a
>      reference-counted object must itself be reference-counted; a
>      mark/sweep object with a finalizer will render the reference-counting
>      ineffective.
>
> That said, it is possible to write a reference-count class in Ruby, but it
> will have limitations.  I've hacked a pure Ruby implemetation together,
> but it is not pretty, and the object itself never goes away (but the
> finalize method does get properly called).  Perhaps someone else already
> has a good implementation, since this topic has come up on the ML before?
>
> Paul
>