[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: PATCH: Fully Resumable VM (yield acrosspcall/callback/meta/iter)
- From: Mike Pall <mikelu-0502@...>
- Date: Wed, 16 Feb 2005 15:01:39 +0100
Hi,
Vijay Aswadhati wrote:
> [1] http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
Interesting. Control inversion for die-hard C programmers. :-)
> At the end of the article the author alludes to having a context to make the
> proposed scheme more robust; I thought that with the Lua State providing
> such a context, there may be some interesting paths that can be explored -
> someday when I have time...
Lua coroutines already have that context. It's called local variables and
they are stored on the value stack (which is anchored at lua_State).
So while we are on the topic of control inversion, here are the two
canonical examples in Lua (I posted one before):
for k in coroutine.wrap(function()table.foreach(_G,coroutine.yield)end) do
print(k)
end
table.foreach(_G,coroutine.wrap(function(k)print(k)
for k in coroutine.yield do print(k) end end))
Both need my patch (but for different and non-obvious reasons -- try to
find this out and you gain a deeper understanding of the VM).
Do I qualify for the IOLCC (International Obfuscated Lua Code Contest)?
Ok, I guess Lua does not lend itself well to obfuscation. Fine with me.
Bye,
Mike