[gambit-list] Never mind. Was: Re: How to give gsi an end-of-file

Marc Feeley feeley at iro.umontreal.ca
Thu May 2 09:14:10 EDT 2013


On 2013-05-02, at 8:54 AM, Hendrik Boom <hendrik at topoi.pooq.com> wrote:

> On Thu, 02 May 2013 12:35:32 +0000, Hendrik Boom wrote:
> 
>> I'm running a gambit program from a file using gsi, initiated from an
>> interactive shell provided by my window manager on Debian wheezy..
>> 
>> The program uses read-char and peek-char to read characters from
>> standard input, which appears to be the terminal.
>> 
>> but the test for end of file, (eof-object? c), seems never to return
>> true,, even if I type a control-D, which is the usual Linux way to
>> signal end of file from a terminal.
>> 
>> How should I enter an end-of-file on the terminal instead?
> 
> Never mind.  I must be doing something else wrong, because I just got it 
> to work in a very small test. Sorry.  I though the test I had used was 
> small enough, but evidently not.  I must have managed to squeeze another 
> error into it.
> 
>> -- hendrik

OK.  Please note that when run in "interactive mode" from the shell, gsi will connect the controlling terminal to current-input/output-port .  If you want stdin/stdout instead, then add the -:d- option.  This feature is useful to be able to debug with a REPL on the controlling terminal a Scheme program which has its stdin/stdout redirected.

Note also that "end-of-file" is not permanent on the terminal.  If you read end-of-file (user typed ctrl-d) you can still read other characters after that.  For example :

> (for-each (lambda (x) (pp (read-char))) '(1 2 3 4 5))
#\newline
#!eof

#\newline
#!eof
#!eof

The output was obtained by typing : ctrl-d, return, ctrl-d, ctrl-d .

Marc




More information about the Gambit-list mailing list