lua-users home
lua-l archive

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


On Wed, Mar 28, 2012 at 1:37 PM, Axel Kittenberger <axkibe@gmail.com> wrote:
> The more you work with immutables, the easier it gets.

True, but using Lua we are restricted, and luvit is a similar kind of
solution to the single-threaded issue as Node.js is for JavaScript.

I must say that _coroutines_ make writing async-style code so much
more pleasant. For instance, in this snippet that sets up a Windows
named pipe server:

winapi.make_pipe_server_async(function(f)
    while true do
        local res = f:read()
        if res == 'close' then break end
        f:write(res:upper())
    end
    print 'finis'
end)

the file object f is wrapped (a la Copas) so that it is not actually
blocking on reads. Getting the write to be non-blocking continues to
be an interesting exercise...

Similar tricks are possible for making waiting-on-processes coroutine-friendly.

steve d.