[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Leaving objects permanently on the stack
- From: Peter Shook <pshook@...>
- Date: Thu, 19 Jun 2003 04:03:14 -0400
Tobias Käs wrote:
Is it safe to leave objects on the stack for faster access, using
absolute stack indices?
I consider this to avoid getting the same tables from the registry, each
time a C function needs it (I have several of this kind).
If you mean after calling lua_open(), to push some values on the stack
before running your script so that you can access them in your
C-function, then the answer is no you can't do that. Inside any
C-function called from a Lua script, stack index 1 is the first argument
passed to the function.
You could make you C-function a C-closure that keeps your table as an
upvalue. See lua_pushcclosure and lua_upvalueindex.
- Peter Shook