[gambit-list] I/O issues (longish)

Christian christian at pflanze.mine.nu
Sun Jan 29 18:41:58 EST 2006

At 15:18 Uhr -0500 29.01.2006, Marc Feeley wrote:
>On 29-Jan-06, at 9:55 AM, Christian wrote:
>>I'm trying to write a program which I can use as wrapper around gambit
>>in interactive sessions, especially in emacs, to provide more sensible
>>buffering for making output appear faster in emacs.
>It will take some time before I have a chance to digest your message 
>fully.  However, concerning "a more sensible buffering" of output, I 
>have recently added control over buffering which should satisfy your 
>needs.  Have you overlooked this or is there a problem with this 

I've missed it - thanks, that's good.

>Specifically, you can select the buffering type for the terminal 
>with  runtime options:
>     gsi -:tu     unbuffered
>     gsi -:tn     newline buffered
>     gsi -:tf     fully buffered

I've noticed that the repl flushes output, so I can even use -:tf, 
cool. That's probably enough most of the time.

Only one minor thing which I envisioned in my wrapper is missing: 
flushing the output periodically (that would basically give the same 
impression as unbuffered output, so even if some code outputs "what's 
the value of x?: " and doesn't flush or so, it is seen by the user). 
I've tried out starting a flushing thread, which works, but hitting 
ctl-c in the repl then just stops the flushing thread, and, 
strangely, doesn't print anything about the interruption until I 
enter something other than only hitting return:

>  (let ((out (current-output-port)))
        (letrec ((lp (lambda ()
                       (thread-sleep! 0.1)
                       (force-output out)
                       (lp)))) lp))))
#<thread #2>
>  (thread-start! (make-thread (lambda ()
				(let lp ()
				  (thread-sleep! 1)
				  (display ".")
#<thread #3>
>  .....<ctl-c><return>
------------- REPL is now in #<thread #2> -------------
*** INTERRUPTED IN ##thread-sleep!

After hitting ctl-c, the dots stop being output; nothing happens 
anymore. Hitting return just scrolls up the terminal output, nothing 
happens. Entering 5 and hitting return gives a 5 as result and 
finally, the "REPL is now in ..." output appears. Why does it not 
show up immediately? Note that this even happens with -:tu.

Other question: can I protect a particular thread (#2 in this case) 
from being interrupted? Something like SIG_IGN signal masks for each 
thread. With this, I could hide the flushing thread from the user. 
And yet another question: is it possible to list all threads which 
are waiting in a REPL, and to change "REPL input focus" to an 
arbitrary other one of them? Sorry for my many questions (if at one 
point I understand enough of Gambit's internals, I might find out 
myself or even code it, but that will take some time).


More information about the Gambit-list mailing list