On Fri, 2006-05-19 at 00:34 +0900, Daniel Schierbeck wrote:
> Ross Bamford wrote:
> > On Thu, 2006-05-18 at 23:55 +0900, Daniel Schierbeck wrote:
> >> I know this has been on the table before, but I really see no reason not 
> >> to allow do/end blocks to have rescue clauses on them, i.e.
> >>
> >>    foo do
> >>      bar
> >>    rescue
> >>      baz
> >>    end
> > 
> > Just playing Devil's Advocate, what'd happen with this:
> > 
> > 	File.open('somefile') do |f|
> > 	  puts f.read
> > 	end rescue puts "Can't open"
> 
> The same as there would now; since the rescue clause is not inside the 
> do/end block, it is not affected by this proposal.
> 
> The difference would be that your version would also rescue exceptions 
> raised by File.open, while the proposed syntax would only rescue 
> exceptions raised within the block given to File.open.
> 

Does that mean that with the proposed syntax, to rescue an exception
from this File.open, we'd have to use:

	begin
	  File.open('somefile') do |f|
	    puts f.read
	  rescue
	    # exception from f.read
	  end 
	rescue
	  # exception from File.open
	end

> But I like the devil's advocate approach, it makes the proposals sharper :)

:) In truth, I think I'm in favour of this change, especially if it
could be done so that the rescue catches exceptions from the block _as
well_ as those from the method to which the block is attached (if any).

-- 
Ross Bamford - rosco / roscopeco.REMOVE.co.uk