Beginning Lua Programming by Kurt Jung Aaron Brown

Beginning Lua Programming by Kurt Jung Aaron Brown

Author:Kurt Jung, Aaron Brown
Language: eng
Format: epub, pdf
ISBN: 9781118079119
Publisher: Wiley Publishing, Inc.


The Debug Library

The debug library includes various functions for looking under the hood of Lua code. These functions are available in the table debug.

Use the debug library with caution. Its functions violate the normal rules of what values and variables are accessible from where. These functions can also be slow. Unless you are writing a debugging tool or something else that needs to poke around in Lua's guts, you probably don't want to use the debug library.

All of the functionality described in this section is also available from C. In cases where speed is important, you may want to work from C rather than Lua.

Inspecting and Manipulating Running Code

Some of the debug library's functions enable you to look at and alter running functions and their variables. In the following Try It Out, you use these functions to access local variables that are not in scope.

Try It Out

Accessing Out-of-Scope Locals

1. Type the following into the interpreter:

I = "global" function Inne local I = "inside Inner, outside loop" for I = 1, 10 do if I == 5 then debug.debug() end print("I (inside loop): " .. I) end end function Outer() local I = "inside Outer" Inner() end



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.