lua-users home
lua-l archive

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


On 25.06.2012 20:03, Michal Kottman wrote:
> On 25 June 2012 19:34,  <meino.cramer@gmx.de> wrote:
>> Hi,
>>
>> (Warning! Newbie ahead!)
>>
>> With UNIX systems you can build chains of cammands
>> on the commandline eacht connected via stdout/stdin.
>>
>> Is it possible to chain lua-functions in a similiar way, that is:
>> To create an output stream with one function which gets the
>> input stream of another function?
>>
>> Is taht possible (portable...)?
> 
> You can implement this kind of chaining (source -> filter -> ... ->
> filter -> sink) using this code [1] by Diego Nehab, which is also
> extensively used in LuaSocket. It is a very interesting reading and I
> suggest you read through it.
> 
> [1] http://lua-users.org/wiki/FiltersSourcesAndSinks

I was going to suggest it also. In addition, I like this (i)Stream
implementation within luvit:
https://github.com/luvit/luvit/blob/master/lib/luvit/core.lua#L211
https://github.com/luvit/luvit/blob/master/examples/tcp-echo-server.lua

Regards,
miko