|
On Feb 16, 2010, at 2:33 PM, Norman Ramsey wrote:
It would be very strange to write code with a variable that is (A) declared outside the loop, and (B) re-declared inside the loop, where (C) looping is contingent on the value in the outer scope, not the inner scope. OTOH, it's often useful for the 'until' condition to be in block scope. Unfortunately, while loops cannot benefit from this, but they could with my favorite looping construct (from a language long forgotten to most)... loop ... while <cond> do ... repeat Much nicer than what I often end up writing in Lua: while true do ... if not <cond> then break end ... end
The current reference manual seems fairly unambiguous on this point: "In the repeat–until loop, the inner block does not end at the until keyword, but only after the condition. So, the condition can refer to local variables declared inside the loop block." -bhk |