XREPL: eXtended REPL
xrepl扩展了racket的默认repl。xrepl会在xrepl-lib安装了的时候自动启用。
raco pkg install xrepl
raco pkg install xrepl-lib
1 Meta REPL Commands
xrepl命令以meta命令的形式实现,这些命令以,开头,比如,exit
。
1.1 Generic Commands
,help [<command-name>]
或者,h
,,?
。
,exit [<exit-code>]
或者,quit
,,ex
。
,cd [<path>]
,讲current-directory设置成指定路径。
,pwd
显示当前路径。
,shell <shell-command>
,跑一个shell命令,简化版:,sh
,,ls
,,cp
,,mv
,,rm
,,md
,,rd
,,git
,,svn
。
,edit <file> ...
,调用$EDITOR
来编辑文件,如果$EDITOR
没有设置,那么则调用d,rracket
,简版,e
。
,drracket [-flag] <file> ...
,简化版,dr
,,drr
。-flag
可以是-new
,-open
,-quit
。
1.2 Binding Information
,apropos <search-for> ...
,查找某个绑定,简化版,ap
。
,describe [<phase-number>] <identifier-or-module> ...
,描述一个受绑定的标识符,简化版,desc
,,id
。
,doc <any> ...
,调用Racket的帮助文档。
1.3 Requiring and Loading Files
,require <require-spec> ...+
请求一个模块。简化版,req
,,r
。
,require-reloadable <module> ...
加载一个模块,确保它可重新加载。简化版,reqr
,rr
。也就是compile-enforce-module-constants
要关掉。
,enter [<module>] [noisy?]
加载一个模块,并套用它的命名空间。简化版,en
。
,toplevel
推到顶层。
,load <filename> ...
,加载一个文件,简化版,ld
。
1.4 Debugging
,backtrace
,查看异常的回溯。简化版,bt
。
,exn [id]
,查看之前的异常。
,time [<count>] <expr> ...
,对表达式的执行进行计时。
,trace <function> ...
,跟踪一个函数。简化版,tr
。
,untrace <function> ...
,关闭对一个函数的跟踪。
,errortrace [<flag>]
,注入错误跟踪。简化版,errt
以及,inst
。
,profile [<expr> | <flag> ...]
,剖析器控制。
,execution-counts <file> ...
,方便使用errortrace。
,coverage <file>
,查询执行密度。
1.5 Miscellaneous Commands
,switch-namespace [<name>] [? | - | ! [<init>]]
切换到一个不同的repl命名空间。
,syntax [expr] [<flag> ...]
,设置对一个语法对象的检查。简化版:,stx
,,st
。
,check-requires [<module>]
,检查一个模块的require
。
,log <opt>
,控制log输出。
,install!
,把xrepl加入启动文件。
2 Past Evaluation Results
通过^, ^^, ……可以显示前几次的计算结果。但是#<void>
结果不算在内。你也可以使用$1,, $2,…… $5来表示相应的信息。
值是以弱引用存在的,所以有可能被垃圾收集器回收。
3 Hacking XREPL
展示如何自定义XREPL。
(本篇完)