lua-users home
lua-l archive

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

If I define a function thus:

foo = function()
       print("foo called")

Then set

bar = foo

Is there any way later in the execution of the program that I can
retrieve the source Lua code of foo from bar?

If you need to save the function back to disk, and don't care about
readability, look at string.dump()

If you need readability, you probably should use debug.getinfo(), it
provides some source file/line information. But you'll need to have
foo source text at hand, and would have to not strip debug information
from the compiled code.