lua-users home
lua-l archive

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

On Nov 23, 2013, at 7:11 PM, Paul Merrell <> wrote:

> Hi, all,
> Doing some playing with Lua 5.2's goto for branching a script
> depending on the string variable returned by an application API
> method, in my test case, a method returning the name of the host
> operating system. But thus far, I have been unable to persuade goto to
> accept a string variable as the target label. I get a missing name
> error for the variable label's name. Is this a known limitation or is
> there some way to write something like:
>  {snip}
> ? If so, I would appreciate a pointer on the correct syntax for the
> first goto line.

In vanilla Lua there is no way to perform a computed goto.

However, I am just putting the finishing touches on my jump table patch which, along with adding a very efficient select/case, also allows the use of computed gotos.

This new feature adds a "jump table" to each closure in which the label (actually an offset into the constant pool), the syntax level the label was declared at, and the program counter offset from the start of the closure to the label. The jump table is also saved when the script is compiled!

I don't know if you are interested in using patched Lua or not, but if this patch interests you I hope to have the first version of the patch out imminently. :)