lua-users home
lua-l archive

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


On Sat, Apr 25, 2009 at 4:24 PM, Phoenix Sol <phoenix@burninglabs.com> wrote:
> Is it safe to assume that it would be relatively easy to implement
> 'message-passing-style-scheduling' in lua, where one coroutine yields to
> another by passing a message to it? (without accumulating stack frames?!)

coroutine.yield can be passed whatever arguments you want, which
become additional return values of the call to coroutine.resume which
caused the coroutine to run. This allows for a coroutine to pass
values as it yields. Also note that extra arguments to
coroutine.resume will become the return values of coroutine.yield in
the resumed coroutine, allowing you to pass values as you resume.