lua-users home
lua-l archive

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

So I am making progress learning the C API but there is something fundamental I am still mixed up about.

After we create a Lua state most of the functions take a pointer to it:

lua_DoSomething( Lua_State *L )

I assume that this is a complex struct that contains the stack mechanisms.

However rereading this in PIL2, on Page 241:
An important concept here is the stack is not a global structure, each function has it's own private local stack

If I push a string onto the stack and then push a number are they not sitting on the same data structure? In the Factor language it looks like they are but they are in fact not, from what I remember it is some sort of overloaded facility. Factors core is in C++, Lua is not, so I don't get how it could be overloaded and I don't understand how each function has it's own stack but "the stack"(as in singular) gets this value or that value if that is the case.

Could someone straighten me out?

Thanks for reading-Patrick