[gambit-list] web-repl.scm behaving strangely

Marc Feeley feeley at iro.umontreal.ca
Wed Nov 8 07:18:40 EST 2006

Hash: SHA1

On 8-Nov-06, at 1:20 AM, Andrew Lentvorski wrote:

> I'm trying to execute web-repl.scm from the repl rather than from the
> command line.  If I comment out the (start-repl-server), I get this:
> Gambit Version 4.0 beta 20
>> (load "web-repl")
> "/Users/gambit/src/gambc-4.0d20/web-repl.scm"
>> (start-repl-server)
> ; I do telnet 7000 and the repl responds on the starting tty
> Gambit Version 4.0 beta 20
> 1>
> ; rather than on the telnet session
> What's going on?  This same program works fine if I uncomment the
> (start-repl-server) and invoke it using "gsi web-repl".  The prompt
> works just fine on the telnet session.
> What am I missing?

Each thread is associated to a "REPL channel", which is the I/O  
channel that the thread will use for interaction with the "user".   
Initially a thread has no associated REPL channel.  At the first REPL  
interaction (writing the prompt or error message, reading the user's  
command, etc) an I/O channel will be assigned to the thread.  If you  
know UNIX, this is very similar to how the "controlling tty" is  
allocated to a process.  This approach is interesting because you can  
redefine the procedure ##thread-make-repl-channel (in your  
initialization file, in a script, etc) **before the first REPL  
interation** to change where the primordial thread's REPL will do I/ 
O.  This is used by GUIDE to redirect the primordial thread's REPL to  
the IDE.  For details read lib/_repl.scm and lib/guide/_guide.scm .

Back to your specific problem, if you load web-repl interactively,  
the primordial thread already has an associated I/O channel (because  
it has already interacted with the user) so it will not be redirected  
to the network connection.  However, if you uncomment the (start-ide- 
repl-in-new-thread) in web-repl, then each telnet connection will  
start a new thread which will use that connection for its I/O channel.

There is also another issue which may confuse you here.  The meaning  
of (current-input-port) and (current-output-port) depends on whether  
you started gsi in interactive mode (with a REPL) or in batch mode.   
In batch mode you will get ports that correspond to the stdin/stdout  
of the process.  In interactive mode you will get ports that  
correspond to the REPL channel, which is normally connected to the  
console (UNIX controlling terminal) rather than stdin/stdout (unless  
you start gsi with the -:d- option).


Version: GnuPG v1.4.3 (Darwin)


More information about the Gambit-list mailing list