[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: More on environments and objects
- From: Mark Hamburg <mhamburg@...>
- Date: Sun, 28 Aug 2005 10:25:12 -0700
on 8/27/05 8:04 AM, Rici Lake at email@example.com 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.