From: Phlip Date: 2007-10-08T08:41:38+09:00 Subject: Re: The old File.rename not working again. . . . Jay Levitt wrote: > In Ruby, though, the object gets destroyed by garbage collection, not by > explicit destruction or stack unwinding. So RAII wouldn't work; you can > never guarantee when (or if) the resource will be closed. Instead, > resource-wrappers like File often let you specify a block; the wrapper > opens the resource, yields to the block, and closes the resource for you. > It's just a different wrapping idiom. If you haven't discovered > http://gotapi.com already, load up the Ruby tab and check out IO#open. A FAQ on the C++ mailing list is "shouldn't C++ learn from Java and add a 'finally' keyword"? Block closures teach us that both RAII and 'finally' are hacks, and the Execute Around Pattern is the Real Deal. -- Phlip