lua-users home
lua-l archive

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


I do understand that it is not likely that this patch will be adopted into PUC-Rio Lua, but I am still interested in having someone take a look at my patch to see if I have made any errors or omissions.
David

On Sat, Mar 18, 2023 at 8:29 AM Paul Ducklin <pducklin@outlook.com> wrote:
>This should really help to reduce
>unnecessary if-statement nesting
>inside loops

If history is a good guide (given the number of times this has been discussed before), you can be pretty certain that ‘continue’ will never come to Lua, so your patch will be forever non-standard.

Therefore any of your code that uses it will require your users to download “your” Lua variant, or to experience compile-time disappointment if they try to run it with a standard version of Lua they’ve already got on their system.

Just put a label at the end of your loop (you can even call it ::continue:: if you like) and use a forward goto. Problem solved.

Or code the loop body as a nested function and return from it whenever you want to skip evaluation early in an iteration.

The nice thing about Lua is that its compact grammar and implementation means you can easily modify it to be more like some other language you already know and like.

The other nice thing about Lua is that you almost always find you don’t need to, and that you might as well stick both to the spirit *and* the letter of the PUC-Rio implementation.