[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why do lua_open* functions leave stuff on the stack?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 02 Oct 2003 15:06:11 -0300
> What's the table? Docs mention nothing about a table on the stack after
> calling these.
Which docs? As far as I know, there are no docs about them :)
All functions that open libraries are C functions (lua_CFunction).
(Actually, with loadlib, they may be real C functions in Lua.) As
such, they follow the protocol for C functions. That protocol says that
the function may leave garbage and results on the stack. If you check
openstdlibs (in lua.c), the code that opens the libs, you will see this:
for (; lib->func; lib++) {
lib->func(l); /* open library */
lua_settop(l, 0); /* discard any results */ <<<<<<<<<
}
-- Roberto