>>>>> "C" == Chris Pine <nemo / hellotree.com> writes:

C> I don't understand.  Are you saying there's a temporary reference to the
C> class?  

 Yes,

C> This code does NOT remove the class Foo:

C>   class Foo; end
C>   Object.module_eval { remove_const 'Foo' }
C>   GC.start

 In this case, some where on the stack, it exist an object which reference 
 Foo (this can be a node, or anything else)

C> But this DOES remove it:

C>   eval 'class Foo; end'
C>   Object.module_eval { remove_const 'Foo' }
C>   GC.start

 Your code is just different, and in this case no object reference Foo

C> So I just wanted to know why.  If you are saying there's a temporary
C> reference, why is it avoided by using 'eval' (or sometimes *caused* by using
C> 'eval')?  Is there a way I can get rid of this temporary reference?

 no : this is why the GC is called "conservative". It can mark object, that
 normally don't exist but it's not important. When you write

   class Foo; end
   Object.module_eval { remove_const 'Foo' }

 Now it's not possible to access the class Foo. 


Guy Decoux