开发者

Clisp REPL error output: how to find line number in file where error occurred?

I'm working through Land of Lisp, using CLisp, writing the code in Vim with Slimv, then alt-tabbing to another terminal wi开发者_如何学Pythonndow and loading the file into the REPL with (load 'file.lisp), then running the programs at the REPL.

When I get an error in the REPL, is there any way to ascertain what line in file.lisp the error occurred on? I don't see line numbers mentioned explicitly in the REPL error output, is there any other way?

I found this similar question, but the only answer says to use something other than Clisp like sbcl, allegro, etc.:

How can I improve clisp error messages?

Thanks!


Simple answer: Just compile the code instead of loading it into the REPL: clisp -c file.lisp. Compiler error/warnings show the line numbers. Debug it that way, then load into the REPL. Good enough for now.


If you just want to know what function it occurred in, you can use ":bt" at the REPL prompt when an error happens. It'll print out a GDB-like stacktrace that you can use to figure out which function the error happened at.


The load function in clisp has an :echo option, see the implementation notes. When you use this option your files gets echoed to the output. Hence when an error occurs you can see the corresponding code. For your case the expression would be:

(load 'file.lisp :echo t)

Some extra options may be useful, such as :verbose and :print, in which case the expression would be:

(load 'file.lisp :verbose t :print t :echo t)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜