From: Shugo Maeda Date: 2012-03-05T16:10:40+09:00 Subject: [ruby-core:43071] Re: [ruby-trunk - Feature #6070] The scope of for loop variables Hello, 2012/3/1 George Koehler : > This patch (for_loop_scope_fix_0224.diff) introduces a confusing change. With current Ruby, for loops and loops never have local variables. With this patch, for loops have local variables, but while loops never have them. Here is a brief example. Yes, it is what I have expected. > With for_loop_scope_fix_0224.diff, it is difficult to understand why for loops can restrict scope of variables, but while loops never do so. Without the patch, the behavior of for loops is consistent with that of while loops; however, it is inconsistent with that of blocks. By contrast with the patch, the behavior of for loops is consistent with that of blocks; however, it is inconsistent with that of while loops. So there's a trade-off between these two design choices. For loops are syntactically close to while loops, but for loops are semantically more close to blocks, so I think it's better to make for loops consistent with blocks. -- Shugo Maeda