[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua 5.0 Alpha and api_incr_top
- From: Björn De Meyer <bjorn.demeyer@...>
- Date: Thu, 19 Sep 2002 22:09:09 +0200
Joshua Jensen wrote:
> This presumes that people operate with Lua in a prescribed way. My
> situation does not fit this. Instead, it works with intertwined data,
> some of which is left on the stack for extended periods of time. When
> the process is finished, the stack is, of course, clean, but it can
> require, depending on size of data, hundreds or thousands of stack
> entries (big databases).
> You might say I am doing this incorrectly, but I am doing this very
> efficiently, because stack access is lightning fast, whereas
> lua_getref() access time has increased considerably since the Lua 4.0
Sorry, but I must say I disagree with you here. If there is a problem
with the perfomance of lua_getref(), then that should be tackled.
And, LUA 5 has the registry, which is very handy to store long-lived
C data in. I do not know anything about the performance of the registry,
but maybe the focus should be on improving the registry's performance.
LUA is not FORTH. In Lua, like in many other programming
languages, the stack is not ment to be a (semi-) permanent
storage area, but rather a way to exchange data between functions.
You only pop your arguments from the stack. When the function
returns, only the results of the function are left on the stack.
This is a Good Thing(tm).
In languages like C and C++, that type of stack hygene is enforced
by the compiler. Lua, probably for performance reasons, does not
enforce such a stack hygene, but that doesn't mean that we should
abuse the stack for our own "dubious" purposes.
"No one knows true heroes, for they speak not of their greatness." --
Björn De Meyer