Mathieu Bouchard <matju / sympatico.ca> writes:

> On Thu, 7 Jun 2001, Dave Thomas wrote:
> > matz / zetabits.com (Yukihiro Matsumoto) writes:
> > > Non shadowing, flat local variable scoping, that it tries to emulate
> > > is, in my opinion, not dirty at all.  The dirty part lies in
> > > flatness depending on context, to achieve compatibility.
> 
> The chief cause of problems is solutions.  Especially solutions to
> problems that don't exist in the first place. I haven't seen any good
> reasons to change the way things are right now.

To me, the current behaviour of such a program is a problem:

i = 3
[1,2].each { |i| }
p i
# -> 2

It's a problem since if I had not defined the variable before the block,
I'd enjoy a "undefined local variable".

Recently, I came to conclude that, to understand that behaviour, I have to
think |i| as a (potentially local) assignment rather than a local
temporary aliasing.

That way, it's understandable, I think. But it's rather surprising, the
first time you discover it. Clashes with the least surprise target IMHO.



-- 
Guillaume Cottenceau - http://mandrakesoft.com/~gc/