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.

This is really quite a deep issue. I'm sure I haven't thought through
all the issues yet. I think in principle I'm coming down in favor of
Matz's approach, if for no other reason than the current scheme of
having to assign to a variable outside a block if you want to export
that variable from the block is ugly.

However, there's an interesting side effect of flat scoping. If you
write your programs in neat little methods and classes, it really won't
affect you much, and will probably help you in terms of clarity
(there'll be fewer special cases). However, if you write big
monolithic monsters, this could well end up biting you, as all
variables would have the same scope. Cut-and-paste in this environment
would be dangerous.

And this is where I have some concerns. Right now, Ruby is fairly
agnostic about the style you adopt. You can write Ruby as you'd write
Perl, and you can write Ruby as you'd write Smalltalk. With this
change, it would be less practical to write the monolithic-style of
Ruby program. This might be a Good Thing. But at the same time it's
really the first time that the Ruby language puts that kind of
constraint on programming style. Do we want Ruby to make it hard to
write programs in a certain (dubious) style?


Dave