lua-users home
lua-l archive

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


Vijay Aswadhati wrote:
> [1]

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

    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.