lua-users home
lua-l archive

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


You need to remember that the coroutine support for Lua is not the
same as stackless python. If you really need a 'stackless'
(i.e. heap-allocated stack instead of growing C-stack) language,
you'll either have to use Python or make the changes to Lua yourself.

Heap-allocated stacks have their advantages, the most significant of
which is reduced memory footprint for running lots of
threads. However, they are also generally harder to interface with
external C-code, which is one of the reasons Lua is not in a hurry to
go stackless.
 
You should carefully consider how you are going to implement the
script code. For example, if you want to have a thread per object in
your world (or something like that), and you want to write code to
handle some kind of 'events' layer in the middle where those threads
will block on events, then you would be better off using a stackless
scripting environment. 

Many games have a much smaller number of threads and periodically call
'event handler methods' inside game objects. In this model, a few
extra threads might be used to make longer running code segments not
depend on eachother, but most event handlers are written to run for a
short period of time each time they are called. Here you might start a
different OS-level thread for the scripting environment vs. the
display system (so that slow script code does not hurt frame-rate),
but you won't need many in-script threads. This is very much how my
hobby game project uses Lua.

I'm not sure what Grim Fandango was doing with threads, perhaps
someone can comment.

On Mon, Jun 11, 2001 at 04:20:04PM -0400, Vesselin Iliev Peev wrote:
> By the way, coroutine support in 4.1 would solve all the problems needed for 
> cooperative multitasking, right? (Tell me if I'm wrong). If that is so, there 
> would be no need for patches to Lua 4.0.
> But when will the eagerly awaited Lua 4.1 with coroutine support see the light 
> anytime soon?
> We are well in June already and I'm just wondering if I need to abandon Lua 
> after having studied the documentation of Stackless Python all day. (Boy, that 
> was harsh. Please take no offence tough... )
> Anyway, my hat is off to the fathers of Lua for their efforts to create a 
> better Lua for all of us!

-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net