lua-users home
lua-l archive

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



On Feb 26, 2014 10:09 PM, "Sean Conner" <sean@conman.org> wrote:
>
> It was thus said that the Great Gary V. Vaughan once stated:
> >
> > Interestingly, the first version of this used luaposix to hook up the
> > pipes, which required a lot more code and was considerable more hairy.
> > But most of the overhead is in setting up the pipes, so for no noticeable
> > speedup in execution and swapping a dependency on /bin/sh for a dependency
> > on luaposix, I got to maintain all the low-level grungy pipe hookups
> > instead of letting /bin/sh do the work.
>
>   Actually, there is some stuff you can do.  Like LPeg, you can create Unix
> command objects [1] such that you could do:
>
>         list = {}
>         cmd = U("ls -l") .. U("grep foobar") / "grep-stderr" .. function()
>                         for line in io.lines() do

For maximum fun, use a non-blocking io implementation. You can have arbitrary lua tasklets at any stage of the pipeline, I think.

>                           table.insert(list,line)
>                         end
>                   return 0
>                 end
>         result = R(cmd) -- actually run the command

Doesn't anybody call methods anymore?

Jay