From: Robert Klemme Date: 2003-12-09T00:12:03+09:00 Subject: Re: WeakRef and Object#hash "ts" schrieb im Newsbeitrag news:200312081429.hB8ETig01761@moulon.inra.fr... > >>>>> "R" == Robert Klemme writes: > > R> Hm, not sure what exactly you mean. > > matz is trying to say that it's hard to know if a variable will be gc'ed, > because internally ruby can have reference to the object that you are not > aware. Aha. But "WeakRef.new Object.new" is not supposed to generate any side effects that create additional references to the newly created instance of class Object, is it? At least not, if WeakRef#initialize is unmodified. > R> I was assuming, the line > R> wr = WeakRef.new Object.new > R> leads to exactly one ref (the weak ref to be precise) to the instance. > > yes, it has only one ref. Now write it (like in the original example) > > class WeakRef; end > wr = WeakRef.new Object.new > > and if you are lucky the variable will not be gc'ed because internally > ruby has a reference to it. To prevent misunderstandings: I was talking about the Object instance, not "wr". Currently I can't see how opening class WeakRef and closing it without doing anything else affects the references to the newly created Object instance. Could you please clarify this? Thanks a lot! Regards robert