问题描述
我目前正在尝试深入研究 Racket/Scheme.我的编辑器旁边有一个 (X)REPL 实例,它极大地帮助了我探索该语言.但是,我似乎找不到可以显示函数源代码的 XREPL 命令或宏(或其他任何东西).
I'm currently trying to dive into Racket/Scheme a bit. I have an instance of the (X)REPL running next to my editor, which helps me immensely to explore the language. However, I can't seem to find an XREPL command or macro (or whatever) which would show me the source code of a function.
所有需要的部分似乎都在那里:
All the needed parts seem to be there:
XREPL 的 describe
命令知道文件:
XREPL's describe
command knows the file:
-> ,describe string-join
; `string-join' is a bound identifier,
; defined in racket/string.rkt
; required directly
和 get-collects-search-dirs
知道路径:
-> (require setup/dirs)
-> (get-collects-search-dirs)
'(#<path:/home/richard/.racket/5.2.1/collects>
#<path:/usr/local/lib/racket/collects>)
在我们拥有的事物的反射方面:
And on the reflection side of things we have:
-> (procedure-arity string-join)
2
但是,如果您只想知道如何调用该函数,那么这一切都没有用处.有没有办法访问函数的实现,或者至少是参数名称?
But it all stops short of being useful if all you want to know is how to call the function.Is there a way to access the function's implementation, or at least the parameter names?
或者,这也适用于我 - 某种等同于 help
打开的文档的 in-REPL 纯文本?
Or, which would also work for me - some kind of in-REPL plain text equivalent of the documentation that help
opens?
推荐答案
几周前 XREPL ,describe
命令得到增强,可以打印函数参数名称和合约;来源.
A couple weeks ago the XREPL ,describe
command was enhanced to print the function argument names and contract; source.
这是 Racket 文档中的蓝框"——之所以这么叫是因为它们在 Racket 6 CSS 重新设计之前曾经是蓝色的;现在它们实际上是灰色的:)
This is the "blue box" from Racket documentation -- so called because they used to be blue before the Racket 6 CSS redesign; now they're actually grey :).
您可以通过从 HEAD 构建 Racket 来获得它.否则,它应该在 6.1 之后的下一个版本中.
You can get this by building Racket from HEAD. Otherwise, it should be in the next release after 6.1.
请记住,这似乎仅限于在安装包中具有 Scribble 文档的功能.
Keep in mind that this appears to be limited to functions that have Scribble documentation in installed packages.
这篇关于有没有办法从 Racket REPL 中查看函数的源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!