Hi,

In message "Specifying local and external block parameters (that old chestnut)"
    on 02/10/04, "Gavin Sinclair" <gsinclair / soyabean.com.au> writes:

|I've cannibalised discussion from the "Bugs" thread.  I hope it is a service to
|the community to reopen this.  The poll on RubyGarden votes "make 'em all
|local", closely followed by "leave it unchanged".  Yet the "problem" keeps
|coming up, and the most sensible solution (in my mind) is not represented in
|the poll.

The "solution" changes time to time in my mind.  Currently I'm
thinking of the following:

  * variables assigned by ":=" should be local to the block (or
    possibly local to the nearest compound statements).

  * if ":=" assignee is already defined in outer scope, it should be
    warned (no -w needed, probably), and outer variable is shadowed
    hereafter.

  * all local variables in block parameters (e.g. var in |var|) should
    be treated as if they are assigned by ":=".  other types of
    variables in block parameter should be warned.

  * scope of local variables assigned by "=" will be a nearest "body"
    (method body, class body etc.) consistently.

This does not change the appearance of Ruby code much, unlke <var>
solution.  It is incompatible to the current syntax, for example,

   a = 5
   [1,2,3].each{|a| break if a % 2 == 0}
   p a

prints "2" now.  It will print "5" (with shadowing warning) if we
adopt the changes above.  Since it is not compatible, it will not be
available in the near future.  Perhaps you have to wait until Rite.

							matz.