[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua code generation vs. goto
- From: Norman Ramsey <nr@...>
- Date: Fri, 25 Jul 2008 13:54:22 -0400
> 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
A() -- wrong
P.S. After your code is working you may find it beneficial to migrate
date from mutable local variables to function parameters.