我对 CL 完全陌生,我想学习如何阅读文档字符串并从 REPL 获取其他帮助信息。类似于help(symbol)
Python、symbol?
iPython 或:t
Haskell:i
的 GHCi 中的东西。
所以,给定一个符号名称,我想知道:
- 它绑定到什么样的值,如果有的话(一个函数,一个变量,根本没有)
- 如果它是一个函数或一个宏,那么它的位置参数是什么
- 如果它有一个文档字符串,显示它
- 它来自什么包或文件或何时定义
我发现有(documentation '_symbol_ '_type_)
,但这不是我所需要的。在我可以使用'function
. 然后它只返回文档字符串,它可能丢失或不足以使用该符号。'variable
'compiler-macro
documentation
例如,在 Lisp 中,对于的帮助mapcar
不是很有用(CLisp 的 REPL):
> (documentation 'mapcar 'function)
NIL
我希望能够看到这样的东西:
>>> 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).