mit-scheme-devel
[Top][All Lists]
Advanced

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

Re: [MIT-Scheme-devel] Forcing (read) to read a given character from the


From: Taylor R Campbell
Subject: Re: [MIT-Scheme-devel] Forcing (read) to read a given character from the terminal once?
Date: Sun, 18 Oct 2009 21:24:58 -0400
User-agent: IMAIL/1.21; Edwin/3.116; MIT-Scheme/7.7.90.+

   Date: Sun, 18 Oct 2009 13:40:59 -0700
   From: Derek Peschel <address@hidden>

   My goal is to replace the non-Edwin debugger's "v" command with something
   a little more like an ordinary REPL:

You can enter an ordinary REPL, in the debugger frame's environment,
with the `e' command.

     - The user presses "(" at a debugger prompt.
     - The debugger runs a variant of command/eval-in-current-environment
       which has the effect of passing the "(" to the reader.  If the user
       kills the line, then the "(" is erased.  That's why the subject says
       "once".

Once control enters the reader, killing the line may prove tricky.
When interacting with the usual REPL, the only way one can kill a line
is by talking with the terminal before the line gets to Scheme.

   command/eval-in-current-environment calls prompt-for-expression which calls
   read.  They all communicate via an I/O port which, in this scenario, I am
   assuming is the terminal.  Hopefully I can operate on the port.  The UNIX
   ould be a call to ungetc, but the Scheme documentation doesn't seem to say
   anything about ungetting characters.  Did I miss something?

You can unread a single character with the UNREAD-CHAR procedure.
Unlike ungetc, which fills a buffer guaranteed to have at least one
character's worth of space, UNREAD-CHAR fills a buffer of exactly one
character, no more.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]