lua-users home
lua-l archive

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


Hello,

When one writes:

function a () ... end   -- (which is equivalent to:)
a = function () ... end

We intercept the assignment to `a` and create a table to represent the function (known as reactor):

a = {
    fun = function () ... end  -- the former function
    edges = { ... }            -- list of links
    co = ...                   -- a coroutine to run it
}

Then we set its metatable to allow the call syntax to actually execute `fun`.
The coroutine field permits that a reactor await other reactors:

function d ()
   ...        -- do something
   await(a)   -- await the termination of `a`
   ...        -- then continue
end

AFAIK this feature is not supported by Twisted, as it needs a continuation-like construct, such as coroutines.
Await is actually much more useful than link.

On Fri, Mar 26, 2010 at 4:57 PM, Valerio Schiavoni <valerio.schiavoni@gmail.com> wrote:
Hello Francisco,

this link mechanism sounds very much like the one I was thinking of.
How is it implemented internally ?


--
Francisco Sant'Anna
http://www.lua.inf.puc-rio.br/luagravity/