From: Joao Pedrosa Date: 2007-01-12T02:35:18+09:00 Subject: Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks Hi, > |class Scope < Proc > |end > | > |Examples: > | > |a) > |scope {|a,b; v1, v2| ...} > | > |b) > |scope {|v1, v2| n = 10 } > |p n #error. unknown n > | > |c) > |scope(binding) {|v1, v2| n = 10 } > |p n #prints 10 > | > |Then backwards compatibility could be kept. > > Unfortunately, local variables scope are determined in compile-time, > so that run-time feature like scope you've proposed is too late to > modify local variable behavior. That's right. I anxiously submitted the email just so I could get the idea off of my chest. :-) The examples weren't complete, as the code blocks would need to be run at least once as you hint. > |That's an idea to try to avoid the "bikeshed talks". hehe. :-) > > Unlike FreeBSD people, I _love_ bikeshed talks. ;-) Just to let you even more at easy, my changes to remove some "dangerous anonymous functions" actually helped me to clear up some of my code, because I was able to use the underlying Module which hosted the anonymous functions as the holder of them, just as I was doing with a couple of Hashes before. Actually I still use some anonymous functions now in this same code/library, but they are a little bit safer as they are very targeted, small, and in a common library. The bigger and more dangerous functions have been taken care of for about 8 or so of my libraries. I still need to make the conversion in two more, though. They all follow the same standard/framework. :-) That is, I am not in a hurry anymore and things have been sorted out in my end. I hope you will be able to sort them in your own now. hehe. :-) With safer (local scope) anonymous functions, programmability will be even better soon. I'm looking forward to it. :-) Cheers, Joao