lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hi Olivier,

On Sat, Jul 4, 2009 at 4:52 PM, Olivier Hamel<> wrote:
> Now before I start confusing myself past what I already am (medication isn't
> helping), I'd like someone to confirm that the following description of how
> Lua's data structures are built internally and that I'm not going insane.
> (Just check the src again to make sure, and now I'm certain I'm going
> insane. Probably will become as clear as day once someone actually explains
> it...)
> Create a new state -> Returns a lua_State structure
> With that state you also created indirectly a global_State structure which
> holds the 'real' state (the one all 'threads' share)
> Create a new coroutine ('thread', why can't we use the same terminology?)
> spawns a new lua_State and makes it point to the global_State that it's
> parent points to.

This is all right.

> So lua_State is more of a coroutine instance and global_State holds all the
> real meat of that Lua universe. Now all I need to figure out is what the LG
> structure does. (No bloody clue. It seems to be some sort of marker to
> specify the size of an empty global state and one lua state. Right?)

The LG structure holds everything (most) of what Lua needs for the
required global state and main Lua state. It is useful for malloc'ing
everything needed in one call (among other things). The main state is
special in that it is never collected and is not (supposed to be) used
as a coroutine.


-Patrick Donnelly

"Let all men know thee, but no man know thee thoroughly: Men freely
ford that see the shallows."

- Benjamin Franklin