Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
About the Book
I. The Basics
1. Getting Started
Chunks
Some Lexical Conventions
Global Variables
Types and Values
Nil
Booleans
The Stand-Alone Interpreter
2. Interlude: The Eight-Queen Puzzle
3. Numbers
Numerals
Arithmetic Operators
Relational Operators
The Mathematical Library
Random-number generator
Rounding functions
Representation Limits
Conversions
Precedence
Lua Before Integers
4. Strings
Literal strings
Long strings
Coercions
The String Library
Unicode
5. Tables
Table Indices
Table Constructors
Arrays, Lists, and Sequences
Table Traversal
Safe Navigation
The Table Library
6. Functions
Multiple Results
Variadic Functions
The function table.unpack
Proper Tail Calls
7. The External World
The Simple I/O Model
The Complete I/O Model
Other Operations on Files
Other System Calls
Running system commands
8. Filling some Gaps
Local Variables and Blocks
Control Structures
if then else
while
repeat
Numerical for
Generic for
break, return, and goto
II. Real Programming
9. Closures
Functions as First-Class Values
Non-Global Functions
Lexical Scoping
A Taste of Functional Programming
10. Pattern Matching
The Pattern-Matching Functions
The function string.find
The function string.match
The function string.gsub
The function string.gmatch
Patterns
Captures
Replacements
URL encoding
Tab expansion
Tricks of the Trade
11. Interlude: Most Frequent Words
12. Date and Time
The Function os.time
The Function os.date
Date–Time Manipulation
13. Bits and Bytes
Bitwise Operators
Unsigned Integers
Packing and Unpacking Binary Data
Binary files
14. Data Structures
Arrays
Matrices and Multi-Dimensional Arrays
Linked Lists
Queues and Double-Ended Queues
Reverse Tables
Sets and Bags
String Buffers
Graphs
15. Data Files and Serialization
Data Files
Serialization
Saving tables without cycles
Saving tables with cycles
16. Compilation, Execution, and Errors
Compilation
Precompiled Code
Errors
Error Handling and Exceptions
Error Messages and Tracebacks
17. Modules and Packages
The Function require
Renaming a module
Path searching
Searchers
The Basic Approach for Writing Modules in Lua
Submodules and Packages
III. Lua-isms
18. Iterators and the Generic for
Iterators and Closures
The Semantics of the Generic for
Stateless Iterators
Traversing Tables in Order
True Iterators
19. Interlude: Markov Chain Algorithm
20. Metatables and Metamethods
Arithmetic Metamethods
Relational Metamethods
Library-Defined Metamethods
Table-Access Metamethods
The __index metamethod
The __newindex metamethod
Tables with default values
Tracking table accesses
Read-only tables
21. Object-Oriented Programming
Classes
Inheritance
Multiple Inheritance
Privacy
The Single-Method Approach
Dual Representation
22. The Environment
Global Variables with Dynamic Names
Global-Variable Declarations
Non-Global Environments
Using _ENV
Environments and Modules
_ENV and load
23. Garbage
Weak Tables
Memorize Functions
Object Attributes
Revisiting Tables with Default Values
Ephemeron Tables
Finalizers
The Garbage Collector
Controlling the Pace of Collection
24. Coroutines
Coroutine Basics
Who Is the Boss?
Coroutines as Iterators
Event-Driven Programming
25. Reflection
Introspective Facilities
Accessing local variables
Accessing non-local variables
Accessing other coroutines
Hooks
Profiles
Sandboxing
26. Interlude: Multithreading with Coroutines
IV. The C API
27. An Overview of the C API
A First Example
The Stack
Pushing elements
Querying elements
Other stack operations
Error Handling with the C API
Error handling in application code
Error handling in library code
Memory Allocation
28. Extending Your Application
The Basics
Table Manipulation
Some short cuts
Calling Lua Functions
A Generic Call Function
29. Calling C from Lua
C Functions
Continuations
C Modules
30. Techniques for Writing C Functions
Array Manipulation
String Manipulation
Storing State in C Functions
The registry
Upvalues
Shared upvalues
31. User-Defined Types in C
Userdata
Metatables
Object-Oriented Access
Array Access
Light Userdata
32. Managing Resources
A Directory Iterator
An XML Parser
33. Threads and States
Multiple Threads
Lua States
← Prev
Back
Next →
← Prev
Back
Next →