lua-users home
lua-l archive

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


 > Is there some trick that would allow me to emulate unconditional jumps
 > in plain Lua (even if it kind of hard to implement)?

The standard trick in functional languages is to make every label a
function and every goto a tail call.  If you make the functions nested
local functions you will find this very efficient in Lua.

It is *crucial* that you force tail calls; 'goto A' must translate
into

  return A()

and *not*

  A()  -- wrong



Norman


P.S. After your code is working you may find it beneficial to migrate
date from mutable local variables to function parameters.