From: "W. Kent Starr" Date: 2001-03-13T11:06:25+09:00 Subject: [ruby-talk:12537] Re: FEATURE REQUEST: 'my' local variables On Monday 12 March 2001 09:04, Dave Thomas wrote: > ts writes: > > >>>>> "G" == GOTO Kentaro writes: > > > > G> For example, loop{|a| ... } means as same as the current model. In > > G> loop{|a;b| b = a; .... }, b is a shadowed counter. > > > > Perhaps you can write loop{(a;b) .... } where a and b are new local > > variables in the current scope > > Doesn't that break existing code, though? > > n = 99 > b = a.collect {(n)} > > > I'm wondering: was the idea of having a different block type for scope > protection just too stupid? I've seen no comments about > ruby-talk:12393. > Yes and no :-) Ok, x = 5; loop {{ |y| x = 3; x * y }} protects "x" or...if I _wnat_ to change x with behavior of the block, i use loop { |y| x = 3; x *y } but... suppose I have x = 5; z = 10; loop { |y| x = 3; z = 5; x + (y * z) } what if I want to change x but keep z as before? loop {{ |y| x = 3; z = 5 ...}) _doesn't_ do it! Or, I just noticed I read this wrong. (n) _would_ work, except it also might be confusing, although (as above example) x = 5; z = 3; loop { |y| (x)=3; z = 5; x + ((z) * y} _woeld_ work, but is it also not confusing. Or perhaps... loop { |y| (x = 3); z = 5; x + (z * y)} ? This would require a core change and to avoid that "conventions" are better _if_ we _all_ act in accordance with the "conventions". For me in my code the localization problem does not reallyy matter; if I want to keep x, I just _don't_ use x withing loop { }; but if _my_ code is used within _your_ code as a require or whatever? _That_ I thnk is where the real problem lies. Regards, Kent Starr elderburn@mindspring.com