leftmike / foment

Foment is an implementation of R7RS Scheme.
MIT License
67 stars 4 forks source link

Deliberately hitting C-c in a row will eventually quit the REPL #18

Closed wasamasa closed 7 years ago

wasamasa commented 7 years ago

Output log when hitting C-c quickly:

$ foment
Foment Scheme 0.4
{2261416} =] ^C
{14384} =] ^C
{14376} =]

Output log when hitting C-c slowly:

$ foment
Foment Scheme 0.4
{2261416} =] ^C
{14384} =] ^C
{14376} =] ^C
{14376} =] ^C
{14376} =] ^C
{14376} =] ^C
{14376} =] ^C
{14376} =] ^C
{14376} =]

This is a bit weird because I'm used from other implementations that C-c will either quit immediately, is caught and returns me to the prompt or enters a debug prompt. The above behavior feels as if there's a race condition and being faster than an internal timer will quit the application.

leftmike commented 7 years ago

Please look at Notify and Control-C to see how C-c handling is controlled. Also look at base.scm to see how repl uses it.

If C-c is pressed more than twice in two seconds, then the process is exited (see syncthrd.cpp).

The behavior you describe is deliberate, but that does not mean it can't be improved. What do you suggest?

wasamasa commented 7 years ago

Ah, so it's indeed timer-based and intentional, I see. It reminds me a bit of C-g in Emacs, if you hit it quickly enough in non-windowed mode, you get a prompt asking you whether you'd like to abort Emacs to get a coredump. A message of this kind could make it more obvious what's going on.