Lua - modrpc/info GitHub Wiki

Table of Contents

Overview

Coroutines

Reference Manual

The Language

  • Lua is a dynamicall typed langauge -- variables do not have types, values have types
  • All Lua values are first-class values.
  • There are 8 basic types:
    • nil
    • boolean
    • number
    • string
    • function
    • userdata
    • thread
    • table

Lua Internals

Code organization

  • lua.h: portal to entire LUA "API" (lua_*)
    • macros for value type tags, subtags for numbers, etc.
    • state manipulation: lua_newstate, lua_close, lua_newthread
    • stack manipulation: lua_gettop, lua_settop, lua_pushvalue, ...
    • stack read functions (read stack value in C): lua_type(lua_State *L, int stkidx), lua_tonumberx, lua_toboolean, ...
    • push functions (push C value to stack): lua_pushnumber, lua_pushstring, ...
    • get functions (Lua -> stack): lua_getglobal, lua_gettable, lua_getfield, lua_geti, lua_rawgetp, ...
    • set functions (stack -> Lua): lua_setglobal, lua_settable, lua_setfield, lua_seti, lua_rawsetp, ...
    • load/call functions: lua_callk, lua_pcallk, lua_load, lua_dump
    • coroutine functions: lua_yieldk, lua_resume, lua_status, lua_isyieldable
    • garbage collection functions: lua_gc
    • misc functions: lua_error, lua_next, ...
    • functions to be called from debugger: lua_Hook
⚠️ **GitHub.com Fallback** ⚠️