On Tue, May 20, 2003 at 12:55:59AM +0900, MikkelFJ wrote:
> 
> "MikkelFJ" <mikkelfj-anti-spam / bigfoot.com> wrote in message
> news:3ec7e99c$0$83055$edfadb0f / dtext01.news.tele.dk...
> 
> > { auto(:foo, :cleanup); foo = foo.new } # calling foo.cleanup on scope
> exit
> 
> Thinking about it... isn't this what ensure does?
> 
> begin
>  foo.new
> ensure
>   foo.cleanup
> end
> 
> 
> or from PickAxe
> 
> f = File.open("testfile")
> begin
>   # .. process
> rescue
>   # .. handle error
> else
>   puts "Congratulations-- no errors!"
> ensure
>   f.close unless f.nil?
> end
> 

This makes me think of that posting were somebody wanted to rebind a
proc. If that were possible, we'd be able to do

def auto(*vars, &block)
   begin
     block.rebind(binding).call
   ensure
     vars.each { |x| eval "#{x}.cleanup if #{x}" }
   end
end

or something like that and then

auto(:a,:b) {
 a = Foo.new
 b = Foo.new
}

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

"How do you pronounce SunOS?"  "Just like you hear it, with a big SOS"
	-- dedicated to Roland Kaltefleiter