"unmatched close parenthesis" when SBCL debugger is turned off
Asked Answered
M

1

0

In how to turn off the debugger in sbcl, one of the answers says that the debugger can be turned off by setting *debugger-hook*:

(defun debug-ignore (c h)
  (declare (ignore h))
  (print c)
  (abort))

(setf *debugger-hook* #'debug-ignore)

However, this seems to cause an "unmatched close parenthesis" error in some circumstances. For example, this is what happens in the SBCL REPL when I enter (foo:bar 123), where foo and bar are non-existent:

* (foo:bar 123)
#<FUNCTION DEBUG-IGNORE>
* 
#<SB-INT:SIMPLE-READER-PACKAGE-ERROR "Package ~A does not exist." {100187B653}> 
* 123
* 
#<SB-INT:SIMPLE-READER-ERROR "unmatched close parenthesis" {100187CE23}> 
* 

From my understanding, this "unmatched close parenthesis" error occurs because after the "Package ~A does not exist." error, there is 123) still remaining to be read. When 123) is read, there is an error because the parenthesis is unmatched. This seems to be specific to SBCL, since the "unmatched close parenthesis" error does not occur when I do the above in CLISP.

Since that answer in how to turn off the debugger in sbcl is not entirely correct, how do I actually disable the debugger in SBCL without encountering these "unmatched close parenthesis" errors?

Millda answered 22/9, 2021 at 7:49 Comment(2)
Turning off a debugger does not mean you get no errors. It also does not mean that the program continues after an error without further errors. That's the usual fate of not actually handling an error, but aborting. When the reader reports an error, aborting that reader error does not mean that the rest of the parse succeeds then.Durman
One can try to find a specific abort restart (like one provided of a top-level loop), but which restarts are available is highly implementation and/or context dependent.Durman
C
3

For this specific problem you can call clear-input so that any remaining input to be read is discarded:

(defun debug-ignore (c h)
  (declare (ignore h))
  (print c)
  (clear-input)
  (abort))
Caban answered 22/9, 2021 at 8:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.