forthy42 / gforth

Gforth mirror on GitHub (original is on Savannah)
GNU General Public License v3.0
151 stars 28 forks source link

Ctrl+D and REFILL #22

Open ruv opened 4 years ago

ruv commented 4 years ago

I would expect that in Linux, REFILL should return 0 if a user enters Ctrl+D Enter at the start of a line in interactive mode.

But the actual result: REFILL throws an exception with code -56 (error in "QUIT").

Gforth version: 0.7.9_20200213

Testcase

[: 0 ['] refill catch cr . .  ;] execute \ <Enter> <Ctrl+D> <Enter>

Expected result: it prints 0 0

Actual result: it prints -56 0

ruv commented 4 years ago

A testcase has been appended. It is strange that catch cannot catch this exception.

larsbrinkhoff commented 4 years ago
  1. Why do you execute an anonymous definition rather than use plain interpreted code?

  2. Use ['] in compile state to tick refill.

  3. The link from "appended" doesn't go to a test case.

ruv commented 4 years ago
  1. Plain interpreted code cannot be used since after refill the whole input buffer is replaced. So cr . . will not be executed.

  2. Thanks for the point. It is my typo. Certainly, I used ['] in compiling. I have fixed this typo in the message above.

  3. I use the link to the updated message in the new message for the situation when the new message is read in email client and it is not obvious where something was changed or appended. Nevertheless, I have placed the precise anchor now.

ruv commented 4 years ago

Well, regarding the Backtrace — I overlooked that it prints the result of catch and shows a back trace for the next Stack underflow error, the partial screen content:

[: ['] refill catch cr . .  ;] execute
-56 -4
*the terminal*:8:32: error: Stack underflow
[: ['] refill catch cr . .  ;] >>>execute<<<
Backtrace:

So my conclusion that catch does not catch this exception was wrong.

The updated testcase:

[: 0 ['] refill catch cr . .  ;] execute
larsbrinkhoff commented 4 years ago

Thanks.