[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: On lua5 and embedding
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 31 Jan 2003 10:18:28 +0000
> I (not being aware of how the internals of your co-routines are implemented)
> am wondering why having coroutines now makes general Lua function calls
I guess the main reason is that we had to unroll recursive calls (in the
C code) into loops with an explicit stack. Several local variables in
luaV_execute were automatically saved/restored when that function called
itself recursively; now we must save/restore them manually. The internal
C stack is faster than any external stack that we can code (despite some
books trying to convince you otherwise).
Also, the call/return code is a little more complex, because there are
more different cases to handle (e.g. a "return" may be a real C return,
if the function was called from C, or a stack pop, if the function was
called from Lua).