如何在Common Lisp REPL中查看docstrings和其他符号信息?

sas*_*nin 25 lisp documentation common-lisp read-eval-print-loop

我是CL的新手,我想学习如何阅读文档字符串并从REPL获取其他帮助信息.像help(symbol)Python中,或symbol?在IPython中,或:t:i在Haskell的GHCI.

所以,给定一个符号名称,我希望能够知道:

  • 它有什么样的价值,如果有的话(一个函数,一个变量,一个都没有)
  • 如果它是一个函数或一个宏,那么它的位置参数是什么
  • 如果它有文档字符串,请显示它
  • 它来自哪个包或文件或何时定义

我找到了(documentation '_symbol_ '_type_),但这不是我需要的.我需要知道的价值符号,势必(类型'function,'variable,'compiler-macro,等)之前,我可以使用documentation.然后它只返回docstring,它可能缺少或不足以使用该符号.

例如,在Lisp中,帮助mapcar不是很有用(CLisp的REPL):

> (documentation 'mapcar 'function)
NIL
Run Code Online (Sandbox Code Playgroud)

我希望能够看到这样的东西:

>>> map?
Type:       builtin_function_or_method
Base Class: <type 'builtin_function_or_method'>
String Form:    <built-in function map>
Namespace:  Python builtin
Docstring:
    map(function, sequence[, sequence, ...]) -> list

    Return a list of the results of applying the function to the items of
    the argument sequence(s).  If more than one sequence is given, the
    function is called with an argument list consisting of the corresponding
    item of each sequence, substituting None for missing values when not all
    sequences have the same length.  If the function is None, return a list of
    the items of the sequence (or a list of tuples if more than one sequence).
Run Code Online (Sandbox Code Playgroud)

Rai*_*wig 28

如上所述,Common Lisp具有标准功能:DESCRIBE,INSPECTDOCUMENTATION.典型的Lisp IDE也将这些绑定到键和菜单.

对于标准的Common Lisp功能,大多数IDE通过击键直接链接到Common Lisp HyperSpec文档.

大多数IDE还有按键来显示arglist和文档.还有'空间arglist'功能.

LispWorks的具体示例:LispWorks参数列表信息LispWorks Expressions菜单

我建议您阅读Slime,LispWorks编辑器,Allegro CL的ELI或您正在使用的任何IDE 的IDE手册.


Rör*_*örd 6

关于你获得符号类型的问题:没有这样的事情.或者,更准确地说,符号不仅仅是其他对象的名称,而是自身SYMBOL类型的对象.每个符号都可以包含变量值和函数值.要检查它是否具有变量值,请使用BOUNDP,并检查函数值FBOUNDP.