Get in Touch
 Duration 14 hours

Course Outline

Introduction to Lua

  • A brief history
  • Lua's objectives, capabilities, and design constraints
  • Accessing Lua documentation and tutorial resources
  • Installation of the Lua interpreter
  • Configuration and usage of LuaRocks

Basic syntax and semantics

  • Identifier usage
  • Single and block comments
  • Global variables and strictness enforcement
  • Local variable scope
  • Standalone programs and handling program arguments
  • Compilation units, code chunks, expressions, and semicolon placement

Data types and data structures

  • Primitive types: nil, boolean, number, and string
  • Object types: functions, userdata, threads, and tables
  • Distinguishing between references/objects and basic values
  • The central role of tables in Lua

Introduction to tables and their versatility

  • Utilizing tables as associative arrays
  • Implementing tables as numeric arrays and sequences

Basic control structures

  • Conditional logic: if, then, elseif, else, and end
  • While loops
  • Repeat-until loops
  • Simple for loops

Error handling

  • Comparing return values and exceptions
  • Transforming return values into exceptions
  • Catching exceptions and converting them to return values
  • Managing error levels

Example programs

  • Implementing polynomial evaluation
  • Executing breadth-first search
  • Supplementary practical exercises

Advanced function concepts

  • Using named arguments
  • Object-oriented method calls
  • Working with closures
  • Applying currying
  • Tail calls
  • Multiple assignment and return statements
  • Variable-length arguments (varargs)

Iterators and co-routines

  • The generic for loop mechanism
  • Comparing stateless and stateful iterators
  • Key differences between iterators and co-routines

Metatables and metamethods

  • Practical examples using sets
  • The __tostring metamethod
  • Arithmetic metamethods
  • The __index and __newindex metamethods
  • The __len metamethod

Modules and packages

  • Incorporating existing modules
  • Creating custom modules
  • Structuring modules into packages

Object-oriented programming

  • Core components of OOP in Lua
  • Practical implementation examples

Discussion on more advanced language features

  • Weak tables
  • Finalizers
  • Compilation, evaluation, and dynamic loading

Requirements

Knowledge of at least one other programming language and general programming experience are required. Familiarity with other scripting languages is optional but will facilitate the understanding of Lua.

Related Categories