4 – The Application Program Interface

    Even when we use the term “function”, any facility in the API may be provided as a macro instead. Except where stated otherwise, all such macros use each of their arguments exactly once (except for the first argument, which is always a Lua state), and so do not generate any hidden side-effects.

    The Lua library is fully reentrant: it has no global variables. It keeps all information it needs in a dynamic structure, called the Lua state.

    A pointer to a thread must be passed as the first argument to every function in the library, except to , which creates a Lua state from scratch and returns a pointer to the main thread in the new state.