lua-users home
lua-l archive

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


On Fri, 29 Mar 2013 15:30:20 +0000
Thijs Schreijer <thijs@thijsschreijer.nl> wrote:

> > 
> > Hi everyone,
> > 
> > I'm happy to announce a new version of lua-repl!
> > 
> > For those of you who aren't aware of it, lua-repl is a library to
> > make it easy to embed a REPL similar to the standalone interpreter
> > in your Lua application.  It also comes with a suite of plugins for
> > enhancing itself, as well as a "demo" console REPL that may be used
> > as an alternative to the standalone REPL (named rep.lua).
> > 
> > Version 0.4 includes a few bug fixes, as well as a few enhancements;
> > please consult the changelog for more information.
> > 
> > The source for lua-repl is located on GitHub:
> > https://github.com/hoelzro/lua-repl.  The release tarball is here:
> > https://github.com/hoelzro/lua-repl/archive/0.4.tar.gz
> > 
> 
> I tried it standalone, but is there also a way to implement it into a
> coroutine scheduler? I'm using copas a lot for socket scheduling,
> could it be made to work inside such a setting? Eg. non-blocking over
> tcp?
> 
> Maybe a small example?
> 
> Thijs
> 

How non-blocking do you need it?  As long as you can fetch lines from
an input in a non-blocking fashion, you should be able to call
repl:handleline(line) without interfering with your event loop.
However, expressions like the following:

  for i = 1, 1000000 do
    -- do something
  end

will obviously lock up your program.  I can come with an example
sometime later today.  If you try it out and discover issues, please
let me know, either via e-mail or GitHub issues!  I haven't really had
a chance to test how it operates in an async environment, and would
like to see it used more.  I've started a project to bind lua-repl to
arbitrary event loops (https://github.com/hoelzro/luarepl-evlib), but I
haven't finished it.  Consider it on my to-do list. =)

-Rob

Attachment: signature.asc
Description: PGP signature