This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: readline and guile


Vadim Zaliva <lord@crocodile.org> writes:

> Now I am facing bigger challenge :-) I am trying to write app which
> should be able to do simultaneously 2 things:
> 
> 1. Accept command line user input using readline. it should not be in
> scheme syntax. I mean, I want "QUIT" not "(QUIT)" command.
> 
> 2. Listen to am TCP socket connection and read and process data as it
> becomes available.

You can do this all from Scheme using two or more threads, all from
Scheme in a single thread using select(), or mostly from C, with
callouts to Scheme.  Unfortunately, I don't know readline very well,
so I can't help much there.

My first suggestion is to try to use guile for the user interaction
stuff, including readline on stdin, and the socket-based input.  I am
pretty sure that you can do this multiplexing without mucking around
in C.

The approach that I would try is to have two Scheme threads: one to
handle stdin using readline, and the other one to handle blocking
reads on sockets.  You can drop into C from both threads when input
arrives.

I hope this helps,

-russ


--
ATTENTION, all abducting aliens!  you DON'T need to RETURN them!
             --Erik Naggum, on comp.lang.lisp