From: cjon@... (Cullen J O'neill) Date: 2000-12-02T06:40:02+09:00 Subject: [ruby-talk:6717] Re: Why is WeakRef#__getobj__ missing from the pickaxe book? Dave Thomas (Dave@thomases.com) wrote: : cjon@sapphire.engin.umich.edu (Cullen J O'neill) writes: : > My question is, isn't it a better idea to just get a real reference : > to the object using __getobj__? : There are two reasons I can think of, but neither is a show-stopper. : 1. You're assuming an implementation, which might not be there : forever. But something like this should be in the WeakRef lib. A way to de-weaken stuff that we don't want to let go after all is essential. : 2. You're taking a risk by regenerating the original object : reference. How? If an explanation of how WeakRef works would elucidate this I'd appreciate it... I looked at the code and said: '???' to about half of it. (I'm not really sure how '???' is pronounced, use your own discression). : The downside to using WeakRef the conventional way is a small : overhead during method dispatch as it searches one level up the class : chain. On balance, I'd probably just use it the conventional way. and the fact that you have to turn of GC, what the overhead on that? And how can you be sure it gets turned on again (mistakes happen) in code where weakrefs are getting used all over? It just seems like turning off all GC is too much ... basically getting a ref to the weakref turns GC off for the one object you're looking at which is exactly what is required. Does this seem reasonable? : Dave BTW: Are you the Dave Thomas cited in XP:Installed for the Spicy Chicken Sandwich or the one who coauthored two wonderful books? Cullen J O'Neill -- cjon@engin.umich.edu