lua-users home
lua-l archive

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


For posterity, I've created a fork and branch ("continue") which you can use to obtain a version of Lua with the continue keyword:

https://github.com/no-more-secrets/lua/tree/continue

There is also a test added, testes/continue.lua.  The branch was cut from the master branch as of 2023-03-30 (so it is Lua version 5.4.4+) and adds one single commit containing the enhancement.

David

On Tue, Mar 21, 2023 at 6:16 AM Domingo Alvarez Duarte <mingodad@gmail.com> wrote:

Just in case I've implemented the 'continue' statement (and others) for LJS[JIT] from 5.1 to 5.4:

- https://github.com/mingodad/ljs

- https://github.com/mingodad/ljsjit

- https://github.com/mingodad/ljs-5.1

- https://github.com/mingodad/ljs-5.4

Cheers !

On 21/3/23 0:10, David Sicilia wrote:
Makes sense, thanks for the explanation.  In that case, I will add a corresponding optimization for "if cond then continue ...".  And now looking at my patch, I wrote a bug in that function which actually causes a test failure; I've attached the corrected patch.

David

On Mon, Mar 20, 2023 at 5:00 PM Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> In the absence of a code review, would anyone know the purpose of the
> `break` keyword handling in the `test_then_block` method?  I am curious to
> know what that does so I know whether to modify it or not.  From what I can
> see, the `continue` keyword seems to work properly whether I update that
> method or not, so I'm wondering if it is simply some kind of optimization
> for special cases.

Yes, it is an optimization for the case "if cond then break ...". Without
the optimization, the "if" would jump around 'break' when the condition
is false. With the optimization, the "if" jumps straight to the end of
the loop when the condition is true.

-- Roberto