[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Using a function on multiple stacks
- From: Sean Conner <sean@...>
- Date: Mon, 13 Jun 2011 20:50:09 -0400
It was thus said that the Great Murray S. Kucherawy once stated:
> If I pass a chunk to lua_load() and then use lua_dump() to get the
> compiled form, can I reuse that compiled form in different Lua states, or
> is it only good in the one in which it was compiled?
I've done that successfully, but the routines in question do not refer to
local variables outside their scope, i.e.
-- might not work because bar() refers to a local variable
-- defined outside itself
function bar(x) return foo + x end
You also need to make sure any global variables referenced in the compiled
function are available in the other Lua state as well.