lua-users home
lua-l archive

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


Disclaimer: this is non-authoritative information based on my limited
understanding of 5.0-work0; I don't know what else the Lua authors
might be up to.

On Aug 08, 2002 at 07:39 -0700, Steve Dekorte wrote:
> 
> I remember reading that the new versions of Lua will have coroutines

Yes...

> and something about this involving some platform specific assembly.

No.  That's a different kind of co-routine.  The "coroutine" feature
planned for Lua 5.0 is implemented by the VM interpreter and only
applies to interpreted Lua code.  The coroutines that require a bit of
assembly are a different animal; they can work on conventional
compiled C code.  AFAIK that type of coroutine is not planned to be
added to Lua.  If you want such a thing, it should be very easy to add
it yourself using Edgar Toernig's coro library:
http://www.goron.de/~froese/coro/coro.html

The Lua VM coroutines therefore aren't as general, but have the
advantage that the script program state is explicitly managed by the
Lua VM, and not stored on the C native program stack.  This makes it
much easier to serialize the state of script computation (e.g. for a
game's save/load feature).

> Is this still the case? If so, could you share some of the technical
> details of how you implemented this?

See the above web page for info on native coroutines.  For the Lua VM
coroutines, the idea is to store all information for Lua function
calls in explicit heap-allocated data structures, hooked into the
lua_State and managed by the Lua VM.  If you look at src/lstate.h, and
search for "struct CallInfo", that's the linchpin of the whole thing.

> Also, what platforms will this feature be supported on?

It's just ANSI C, so the usual Lua platforms.

-- 
Thatcher Ulrich
http://tulrich.com