From: Daniel DeLorme Date: 2008-10-02T14:47:20+09:00 Subject: Re: ruby1.9 block scope Daniel DeLorme wrote: > Ok, I now see that it is indeed O(n^2) complex. But you *already* have > to do that for large scopes; you have to consider every variable that > previously appeared in the scope, and that's O(n^2). The new rule would > make it 2*O(n^2) [which, in math speak, is still O(n^2)]. But this is > only a problem if n is very large; if you really have a scope that long > then I dare say that you already have a problem and some refactoring is > in order. Whatever happened to "no more than 10-20 lines per method" ? Sorry, I didn't think this through enough. The new rule would not change the current rule that variables defined at L are not considered as variables at all at lines L-n. So under the new rule, code would have mathematically the *same* complexity but practically it might be more tricky: define_method :foo do #say, 20 lines of code end foobar under new rules, you'd have to backtrack until the top of the scope to see if "foobar" is a variable or not. under old rules, you'd have to backtrack until the top of the scope to see if "foobar" is a variable or not, while taking into account that variables defined in a sub-scope are self-contained, which means that you can skip large sections of indented code. I hope I got it right this time. -- Daniel