The last week I have been browsing compl.lang.ruby at google, on how to
ensure that a resource gets closed correctly.
The destructor[blocks, finalizers] subject has been pretty well covered
on this NG I think. Finalizers should be avoided, because it does stuff
behind peoples bag. People are encouraged to use "block"s. I think I got it.
Is it correct there does’nt exist any “out-of-scope” feature?
Well, I do not think so! I just want to be 100% sure 
···
–
Simon Strandgaard
“Simon Strandgaard” 0bz63fz3m1qt3001@sneakemail.com wrote in message
news:pan.2003.04.07.19.46.06.878571@sneakemail.com…
Is it correct there does’nt exist any “out-of-scope” feature?
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/6966
but I suspect the C-API will allow you to hook into finalize.
Mikkel
I know you can do like this:
def use(resource)
resource.open
yield
ensure
resource.close
end
use(alien_connection) do
# do somethine
end
In order to use it, you must supply a block.
Finalizers gets invoked when a object is being garbage collected. This is
not necessarily when the object goes out-of-scope. Thus finalizers cannot
be used to get notify on “out-of-scope”. Am I right here?
What I wanna make sure is that “blocks” is the one-and-only way to get
notify on “out-of-scope”?
Or is there other options, which im not aware of?
···
On Tue, 08 Apr 2003 03:06:32 +0200, MikkelFJ wrote:
“MikkelFJ” mikkelfj-anti-spam@bigfoot.com wrote in message
news:3e921047$0$136$edfadb0f@dtext01.news.tele.dk…
Is it correct there does’nt exist any “out-of-scope” feature?
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/6966
and then again:
http://www.eng.dmu.ac.uk/~hgs/ruby/RUBY_SNAPSHOT_RDOC/classes/Finalizer.html
http://www.eng.dmu.ac.uk/~hgs/ruby/RUBY_SNAPSHOT_RDOC/files/lib/ruby/1_8/finalize_rb.html
–
Simon Strandgaard
BTW. The reason why im asking is that im writing a text on how to embed
ruby into c++. I don’t wanna write incorrect stuff 
http://metaeditor.sf.net/embed/