On Wednesday, February 5, 2003, 1:47:47 AM, Brian wrote:

> (1) Block parameters - e.g. |i,j| - are always local to the block,
> regardless of whether a variable with the same name already exists. e.g.

>   i = 0
>   [1,2,3].each { |i|   # this is a *different* i (shadowing)
>     puts i
>   }
>   puts i

> will print 1 2 3 0

> I think Matz wants a compulsory warning if you shadow a variable in this way
> (i.e. generated even if you don't specify '-w')


Please justify why this warning is necessary.  The code you give above
is elegant.  The proposed rules make it clear what is meant, and it
satisfies my POLS.  Why is a warning generated?

OTOH, I would expect a warning for _this_ code:

  i = 0
  [1,2,3].each { |i|
    i = 7
  }
  puts i

But that code is clearly garbage anyway, old or new rules.

Gavin