On Jan 3, 2008, at 1:35 AM, Charles Oliver Nutter wrote: > > The problem with this logic is that in case A, the exception also > causes the loop to be terminated as normal: > > while true > eval 'break' > end > > So there's obviously some duality behind break. > > 1. A bare break can't be cause as an exception, and terminates an > enclosing loop > 2. A break inside an eval can be caught as an exception, and also > terminates an enclosing loop like a normal break. OK, I just tried this on my box that has 1.9 installed and I see that the 1.9 behavior in this case is different than the 1.8 behavior. I've been talking about the 1.8 behavior. To summarize: 1.8, top-level, bare break: LocalJumpException 1.8, top-level, eval 'break':LocalJumpException 1.8, loop, bare break: loop terminates 1.8, loop, eval 'break': loop terminates So in 1.8 the loop/iterator context is visible within an eval string. 1.9, top-level, bare break: SyntaxError 1.9, top-level, eval 'break': SyntaxError 1.9, loop, bare break: loop terminates 1.9, loop, eval 'break': SyntaxError So in 1.9 eval is creating a 'stronger' scope than in 1.8 and hiding the loop/iterator context from the code in the string that is being evaluated. In this new, more private, context a bare break is always a syntax error. It doesn't matter where the eval is taking place. I'm not sure I understand you second point above. If you catch the syntax error with a rescue clause within the loop, then the loop won't be terminated. If you don't catch the error then the loop will be terminated. But this is just the normal behavior of any sort of exception--there is nothing special about 'break' in this case--any old syntax error would do the same thing. It seems like the 1.9 behavior is more consistent with the fact that eval does create a new scope of sorts. The fact that the iterator context leaked into the 1.8 eval string scope seems more like a bug than a feature. Gary Wright