From: matz@... (Yukihiro Matsumoto) Date: 2002-10-04T11:37:21+09:00 Subject: Re: Specifying local and external block parameters (that old chestnut) Hi, In message "Specifying local and external block parameters (that old chestnut)" on 02/10/04, "Gavin Sinclair" 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 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.