> From: "Hal E. Fulton" <hal9000 / hypermetrics.com>
> 1. Intuition (for many people) says that the entities in the
> "parameter" list (which really isn't a parameter list, right?)
> are local to the block.
Yes.

> 2. Their intuition is wrong. If Ruby sees a variable in the list
> that already exists, it will use the existing one.
So it only happens on assignment within the block, the variable will be read
from the block parameters withing the block:

irb(main):007:0> x = [1, 2]
irb(main):008:0> y = 77
irb(main):009:0> x.each {|y| puts y}
1
2

but assignment will happen on the variable outside the block:

irb(main):007:0> y=0
irb(main):008:0> x.each do |y|
irb(main):009:1* puts y
irb(main):010:1> y=77
irb(main):011:1> end
1
2
irb(main):012:0> puts y
77


> 5. I still favor the symbol idea -- if a param is a symbol, then it
> refers to the outer scope; if not, it's block-local. This will still
> break old code, but I think it is more intuitive than the reverse
> (which would not break old code). And if it's a symbol, and the
> variable doesn't exist yet, then create it.
>
>   x = 5                            # and y doesn't exist
>   my_meth do | x, :y |
>     x = 6
>     y = 7
>   end
>
>   puts x              # 5  (unchanged)
>   puts y              # 7  (new var)
>

Well, if I'm well enough versed to give an opinion now, I guess I'd say that
I prefer it to work like this:

parameter variables are local to the block - assigning or reading
other variables are searched for by scope - current behavior

So the only thing I would change is not to allow a variable from the
parameter list to be treated as a higher scope variable for assignment.  The
rest of the behavior is least surprise for me.  The symbol idea is less
natural for me to visualize than explicitly declaring a temp variable before
the block is called, then populating it from within the block.

Wayne