lua-users home
lua-l archive

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


on 8/27/05 8:04 AM, Rici Lake at lua@ricilake.net wrote:

>> - Yield from everywhere.
> 
> I'm starting to think that yield is hiding an ambiguity. The fact that
> you cannot use yield to both implement control-inversion and
> thread-scheduling independently makes me wonder if there isn't some
> better way.

At the very least, it takes some careful programming with a special value
meaning "yield-back-to-the-scheduler" and a version of resume that knows to
look for this value. At the same time, one might also implement a version of
yield for the back-to-the-scheduler case that would throw an error rather
than returning if so signaled.

Like call/cc, Lua's coroutine operations are good primitives, but they can
still take some work to make do what you want. They are easier to think
about and a lot closer to being generally useful than call/cc, however.

Mark