From: Robert Klemme Date: 2005-04-13T20:54:42+09:00 Subject: Re: ability to run finalizers at a given point of a program? "ts" schrieb im Newsbeitrag news:200504131121.j3DBLwDA001100@moulon.inra.fr... > >>>>> "G" == Guillaume Cottenceau writes: > > G> After a second thought, I then think that it reduces a lot the use of > G> the finalizer, because it means that it cannot do anything related to > G> the instance of the object being destroyed, Not necessarily: you can keep a reference to a member instance that needs cleanup. Also, the finalizer receives the oid which you can use for bookkeeping purposes. > This is worst that you think > > svg% cat b.rb > #!/usr/local/bin/ruby > obj = [] > ObjectSpace.define_finalizer(obj, proc { p "before"; p obj; p "after" }) > svg% > > svg% b.rb > "before" > svg% Interesting. IMHO the finalizer should not be called in the first place as it retains a ref to "obj". robert