Introspective information

Lua provides the debug.getinfo function to inspect the currently running code. This function takes one of two arguments, either a function or an integer. When the argument is an integer, getinfo will look the specified number of steps up the callstack. For example, let's assume you have the following code:

function one() 
print ("one")
end

function two()
one()
print("two")
end

function three()
two()
print("three")

debug.getinfo(1)
end

Providing an argument of 1 will inspect the function calling debug.getinfo, or function three. Providing 2 will go one more function up the callstack, inspecting function two. Or, providing 3 will look even further up the callstack and inspect function one.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.158.165