From: "Aleksi Niemelä" Date: 2000-11-30T00:07:34+09:00 Subject: [ruby-talk:6633] RE: Why is WeakRef#__getobj__ missing from the p ickaxe book? Cullen J O'Neill proposed: > My question is, isn't it a better idea to just get a real reference > to the object using __getobj__? > > ---- > if ref.weakref_alive? > real_ref = ref.__getobj__ I don't know much about weak references, but I'd guess you risk losing the real object with above code. I feel I would not rely on the fact there happens no GC between alive? and __getobj__. Nevertheless I guess some combination of your's and book's versions would be ideal, while pretty wordy. I don't like the idea GC is disabled, at least for longer periods. Maybe there's demand for weakref.if_alive do |ref| # stuff end And hide the ugly semantics of GC disabling, and allow immediate GC enabling. - Aleksi