From: ahoward Date: 2003-02-03T01:11:21+09:00 Subject: Re: Local variables & blocks On Sun, 2 Feb 2003, Yukihiro Matsumoto wrote: > I agree with you. I was insane when I designed this rule. That's why I > propose the change. But I don't think we can just drop block local > variables like yours, since we have Proc (some kind of anonymous function), > we need some kind of local variables of their own. insane? i don't think so to me this is _natural_ as in Cs int x; { x = 42; } vs int x; { int x; x = 42; } this is expected when one realizes ruby's lhs statement do both declaration in current scope and definition in current scope. how about some simple means on introducing a local scope? a new keyword/method? perhaps 'scope/end' and '{{/}}'. this could allow the programmer to work as wished, added to your current plan one would end up with : [4,2].each { |c| s << c.to_s } puts s # >> 42 [4,2].each {{ |c| s << c.to_s }} puts s NameError: undefined local variable or method `s' for # maybe that syntax is no good, but what would be the problem of allowing programmers to introduce scopes (most languages do)? this would allow to the introduce your new plan, and in cases (like threads) or for people where it might be an imperfect fit you could say 'just introduce a scope and it will be as before'. i guess one could simply use guy's 'local' method, but it would be nice if that were built in for people who like scopes. using this, the default for thread might be to introduce a new scope - there are some cases where POLS means blocks should start a new scope. -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================