dasch wrote:
> In that case I'd expect $global_reference to be nil after the `finalize'
> method is done executing, since the Klass instance has already been
> deemed ready for destruction.

"after the 'finalize' method is done" => Tricky.

How would this be implemented?  Seems to me Ruby would have to scan all 
of the current image to determine if any new references were created 
during the execution of the finalize method.  Especially since the 
references may be created deep inside other methods invoked by finalize.

And it might be more subtle than just checking for variable bindings. 
Consider:

  class NamedObject
    attr_reader :name
    def initialize(name)
      @name = name
    end
    def finalize
      proc { name }
    end
  end

  k = NamedObject.new("Billy")
  p = k.finalize  # Here p is a proc that has a binding that includes
                  # a "finalized" object.

The point is that the current mechanism avoids all these questions by 
only calling the finalizer /after/ the object has been destroyed.

-- 
Posted via http://www.ruby-forum.com/.