I've cannibalised discussion from the "Bugs" thread. I hope it is a service to
the community to reopen this. The poll on RubyGarden votes "make 'em all
local", closely followed by "leave it unchanged". Yet the "problem" keeps
coming up, and the most sensible solution (in my mind) is not represented in
the poll.
I think it makes sense to explicitly mark *external* variables, as block-local
variables (parameters, in fact) would be the norm.
Thus, if 'a' and 'c' are regular parameters and 'b' is an external variable,
then one could write
collection.each do |a,:b,c|
...
end
or
collection.each do |a,b,c|
external b
...
end
I'm not sure which of the above I prefer. One should optimise for the common
case.
I'd like to put a question to the audience :) Does anyone actually have a need
to use non-local block parameters? Ever?
Apologies if this can of worms is better left buried.
Cheers,
Gavin
--
Gavin Sinclair Software Engineer
Sydney, Australia Soyabean Software Pty Ltd