退出SublimeREPL中的sbcl调试器

huangapple go评论57阅读模式
英文:

Exit Debugger in SublimeREPL with sbcl

问题

如何退出SublimeREPL repl中的调试器?我不太擅长猜测按键,而且在文档中没有找到相关信息。以将当前文件发送到repl的方式调用的示例:

在线程中发生了SB-INT:SIMPLE-READER-PACKAGE-ERROR的调试器错误
#<THREAD "主线程" 运行中 {1001834103}>:
  包PPCRE不存在。

    流:#<SYNONYM-STREAM :SYMBOL SB-SYS:*STDIN* {100001B513}>

容易修复,但在调试器中卡住的时候不太容易!错误并不是问题,我再次强调,问题在于我不知道如何退出调试器并返回到repl的顶层。当然,这也适用于repl中的任何错误。例如,文件窗口中的以下代码就足够了:

(count-matches "\\w*" "foo bar baz")

将此代码提交给repl并使用C-,f这个按键组合将会进入调试器,要么因为您没有Quickloaded cl-ppcre库,要么因为您已经加载了它,但忘记在使用时加上ppcre:前缀。正如我所说,任何错误都会使您陷入无法退出的repl状态。

英文:

How do I exit the debugger in a SublimeREPL repl? I'm not very good at guessing keystrokes, and I didn't see anything in the documentation. As an example invoked by sending the current file to the repl:

debugger invoked on a SB-INT:SIMPLE-READER-PACKAGE-ERROR in thread
#<THREAD "main thread" RUNNING {1001834103}>:
  Package PPCRE does not exist.

    Stream: #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDIN* {100001B513}>

Easy to fix, but not while stuck in the debugger! The error is not, I say again, not the problem. What is the problem is that I know of no way to exit the debugger and return to the top level of the repl. Of course, this applies to any error in the repl. For instance, the following code in the file window will suffice:

(count-matches "\\w*" "foo bar baz")

This code submitted to the reply with the keystroke(s) of C-,f will, of course, enter the debugger either because you have not Quickloaded the cl-ppcre library or you have, and it's failing because you forgot to prefix your usage with ppcre: As I said, any error will do, trapping you in a repl state that is useless without a way out.

答案1

得分: 1

I installed the sbcl v2.3.3 MacPorts port on my Mac (OSX 10.15.7) for the purposes of this answer.

First, I created a file test.lisp with the contents:

(count-matches "\\w*" "foo bar baz")

as suggested in the question. Next, I started a REPL by selecting Tools → SublimeREPL → Common Lisp → SBCL. This appeared in a new tab:

This is SBCL 2.3.3, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* 

Switching back to test.lisp, I selected Tools → SublimeREPL → Eval in REPL → File and got this:

* (count-matches "\\w*" "foo bar baz")

; in: COUNT-MATCHES "\\w*"
;     (COUNT-MATCHES "\\w*" "foo bar baz")
; 
; caught STYLE-WARNING:
;   undefined function: COMMON-LISP-USER::COUNT-MATCHES
; 
; compilation unit finished
;   Undefined function:
;     COUNT-MATCHES
;   caught 1 STYLE-WARNING condition

debugger invoked on a UNDEFINED-FUNCTION @52A00904 in thread
#<THREAD "main thread" RUNNING {10013B0003}>:
  The function COMMON-LISP-USER::COUNT-MATCHES is undefined.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [CONTINUE      ] Retry calling COUNT-MATCHES.
  1: [USE-VALUE     ] Call specified function.
  2: [RETURN-VALUE  ] Return specified values.
  3: [RETURN-NOTHING] Return zero values.
  4: [ABORT         ] Exit debugger, returning to top level.

("undefined function" "\\w*" "foo bar baz")
0] 

I then typed in 4 and the prompt changed back to * .

If I started a fresh SBCL REPL and instead chose Tools → SublimeREPL → Transfer to REPL → File, it copied the contents of the file to the * prompt, and I had to hit Enter for it to evaluate. The same debugger message as above came up, and entering 4 successfully brought me back to the * prompt.

While searching for lisp on Package Control, I came across Slyblime, a port of Sly to Sublime Text 4 (make sure you are using build number 4000 or greater - Sublime Text → About Sublime Text on Mac, Preferences → About Sublime Text on Windows/Linux). Slyblime is built on top of SublimeREPL and adds additional features. I don't know enough about Lisp to make use of it or judge its utility, I just thought I'd mention it here.

英文:

<sup>I installed the sbcl v2.3.3 MacPorts port on my Mac (OSX 10.15.7) for the purposes of this answer.</sup>

First, I created a file test.lisp with the contents:

(count-matches &quot;\\w*&quot; &quot;foo bar baz&quot;)

as suggested in the question. Next, I started a REPL by selecting Tools → SublimeREPL → Common Lisp → SBCL. This appeared in a new tab:

This is SBCL 2.3.3, an implementation of ANSI Common Lisp.
More information about SBCL is available at &lt;http://www.sbcl.org/&gt;.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* 

Switching back to test.lisp, I selected Tools → SublimeREPL → Eval in REPL → File and got this:

* (count-matches &quot;\\w*&quot; &quot;foo bar baz&quot;)

; in: COUNT-MATCHES &quot;\\w*&quot;
;     (COUNT-MATCHES &quot;\\w*&quot; &quot;foo bar baz&quot;)
; 
; caught STYLE-WARNING:
;   undefined function: COMMON-LISP-USER::COUNT-MATCHES
; 
; compilation unit finished
;   Undefined function:
;     COUNT-MATCHES
;   caught 1 STYLE-WARNING condition

debugger invoked on a UNDEFINED-FUNCTION @52A00904 in thread
#&lt;THREAD &quot;main thread&quot; RUNNING {10013B0003}&gt;:
  The function COMMON-LISP-USER::COUNT-MATCHES is undefined.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [CONTINUE      ] Retry calling COUNT-MATCHES.
  1: [USE-VALUE     ] Call specified function.
  2: [RETURN-VALUE  ] Return specified values.
  3: [RETURN-NOTHING] Return zero values.
  4: [ABORT         ] Exit debugger, returning to top level.

(&quot;undefined function&quot; &quot;\\w*&quot; &quot;foo bar baz&quot;)
0] 

I then typed in <kbd>4</kbd> and the prompt changed back to * .

If I started a fresh SBCL REPL and instead chose Tools → SublimeREPL → Transfer to REPL → File, it copied the contents of the file to the * prompt, and I had to hit <kbd>Enter</kbd> for it to evaluate. The same debugger message as above came up, and entering 4 successfully brought me back to the * prompt.


While searching for lisp on Package Control, I came across Slyblime, a port of Sly to Sublime Text 4 (make sure you are using build number 4000 or greater - Sublime Text → About Sublime Text on Mac, Preferences → About Sublime Text on Windows/Linux). Slyblime is built on top of SublimeREPL and adds additional features. I don't know enough about Lisp to make use of it or judge its utility, I just thought I'd mention it here.

huangapple
  • 本文由 发表于 2023年4月17日 03:49:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76030008.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定