lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Roberto Ierusalimschy wrote:
Every person I train in Lua asks me why 'continue' doesn't work. I show them the "equivalent", and it never meets with any kind of satisfaction.


I'm in the camp where I see a real need for it in Lua, not only for clarity, but because it is a very useful loop construct that anyone coming from another popular (scripting) language will expect to be able to use.

Any comment about this?

-- Roberto

My expectations are that the difference between the `repeat' and `while' loop constructs should simply be that `repeat' evaluates is block before testing the condition, whereas `while' does the inverse. I find it surprising that the variable in the `until' condition is inside the scope of the loop block.

So my vote would be to add `continue', but hoist the scope of the `until' condition outside the block to make it behave like `while'.

My tuppence.