Hello,

At 09:19 12/06/2002 +0900, Jim Hranicky wrote:
>On Tue, 11 Jun 2002 13:20:03 +0900
>"Minero Aoki" <aamine / mx.edit.ne.jp> wrote:
>
> >   * Backward compatibility takes precedence over all.
> >
> >   * The problem is that block localization may be broken with
> >     name collision between inside of the block and the outside.
> >
> >   * It is not true that ruby does not have block local variables.
> >     The problem is that local variables does NOT shadows outer
> >     local variables.
>
>Should we perhaps take a vote and see how many folks have ruby
>programs that depend on block parameters referencing outer variables?

I have some such parameters, I wish the reference would be more
obvious/readable.

>I've always treated block variables as block local -- perhaps breaking
>backwards compatibility won't have such a huge impact.

I wish block variables had been block local "by default". I have had a few
nasty bugs with it. Now, whenever I select a name for a block variable,
I double check that it is not already in scope... boring.

What about:
   xxx.each do |a, new b|
     xxx
   end
Where "new" asks for a fresh new b (versus the potential one already in
scope). "my" instead of "new" would be more Perlish. "local" maybe ?

Unfortunately I suspect that I would use "new/my/local" variables most of
the time and that, as a result, my code would be cluttered with it.

Had the default been the opposite (i.e. if block variables were local):
   xxxx.each do | a again, b |
     xxx
   end
Where "again" tells that the variable a is the one from the outer scope,
if any.

BTW: I sometimes end up having code like this:
   begin
     my_obj = obj
     xxx do
       xxx my_obj xxx
     end
   end
I need "my_obj" because I want the value of "obj" at the time the block
was *created*, versus the value when the block is *called*. Is there a
shorter way to do this ? When the <> or |;| construction is introduced it
would be nice if it could provide an initial value for the local variables:
xxx do |x; my_obj = obj| # |x;obj = obj| |x, new obj = obj| |x, obj now|
   xxx my_obj xxx         # The stuff after = being evaluated when the block
end                      # is *created*, not when it is called.

BTW: I love the closure thing, but sometimes it makes me nervous that
the binding of the block results in objects being uselessly referenced ;
"ensure x = nil, y = nil, other_vars = nil" is not really a decent option,
is it ?

Jean-Hugues

-------------------------------------------------------------------------
Web:  http://hdl.handle.net/1030.37/1.1
Phone: +33 (0) 4 92 27 74 17