Is there a fast way to exit the debugger in MIT Scheme's REPL?
Asked Answered
M

2

1

Suppose I try to use an undefined variable in MIT Scheme's REPL:

1 ]=> blablabla

;Unbound variable: blablabla
;To continue, call RESTART with an option number:
; (RESTART 3) => Specify a value to use instead of blablabla.
; (RESTART 2) => Define blablabla to a given value.
; (RESTART 1) => Return to read-eval-print level 1.

2 error> 

This automatically brings me into the debugger. To exit the debugger, I have to type (restart 1). Is there an alternative way that does not involve typing 11 characters just to exit the debugger? It's a bit silly that all three options involve typing 11 characters.

Methane answered 29/11, 2020 at 15:32 Comment(2)
Just type ctrl+c ctrl+cSacring
@ÓscarLópez Thank you for the information. I was running MIT Scheme using rlwrap (rlwrap mit-scheme). rlwrap somehow causes the second ctrl-c to be ignored.Methane
T
1

According to Flux's answer, pressing CTRLC twice will work with mit-scheme, but not when it runs within rlwrap

In order to make rlwrap more "transparent" with regard to CTRLC and CTRLG

  • Use the -W (--polling) option: rlwrap -W will make rlwrap wake up every 40 msecs to check whether the client has changed its terminal settings (in your case, its interrupt character)
  • Add a few lines to your .inputrc:
$if mit-scheme
  "\C-c" rlwrap-direct-keypress
  "\C-g" rlwrap-direct-keypress
$endif

Those lines will tell rlwrap (when wrapping mit-scheme) to pass on CTRLC and CTRLG even when in the middle of a line edit.

With those two tweaks, I can't tell the difference anymore in interrupt behaviour between rlwrapped and unwrapped mit-scheme

-W needs rlwrap >= 0.41, rlwrap-direct-keypress >= 0.43

For a more in-depth explanation why this works (and why the options and .inputrc entries are necessary) see this rlwrap issue on Github.

Taille answered 14/2, 2021 at 10:42 Comment(5)
Should the ~/.inputrc entries be enclosed in $if mit-scheme ... $endif?Methane
Typos: -w should be -W, and rlwrap -w should be rlwrap -W instead.Methane
(I corrected the typos, thanks!!). Yes, better enclose the lines in $if..$endif even though you will probably be allright when you don't (as the terminal will catch the CTRL+C before rlwrap can, and CTRL+G is seldom used.Taille
I noticed that I don't even need to add those rlwrap-direct-keypress lines to ~/.inputrc. rlwrap -W mit-scheme alone seems to solve the Ctrl-c Ctrl-c problem. Is this normal?Methane
-W is the more important setting. Without the rlwrap-direct-keypress, for me sometimes the first CTRL+C seemed to misfire. Apart from that, -W on its own will do.Taille
M
0

According to the MIT Scheme user manual's section about interrupting the REPL:

  • C-c C-c
  • C-g

Abort whatever Scheme evaluation is currently running and return to the top-level REPL. If no evaluation is running, this is equivalent to evaluating (cmdl-interrupt/abort-top-level)

So there are two ways to quickly exit the debugger:

  • CtrlcCtrlc — Unfortunately, this method is unsuitable when using MIT Scheme with rlwrap (i.e. rlwrap mit-scheme). When in the debugger, rlwrap somehow causes the second Ctrlc to be ignored.

  • Ctrlg — This works well with rlwrap, and requires less key presses than the above.

Methane answered 10/2, 2021 at 2:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.