私は CL にまったく慣れていないので、ドキュメンテーションの文字列を読み、REPL から他のヘルプ情報を取得する方法を学びたいと思っています。help(symbol)
Python、symbol?
iPython、または:t
Haskell:i
の GHCi のようなものです。
したがって、シンボル名が与えられたら、次のことを知りたいです。
- バインドされている値の種類 (もしあれば) (関数、変数、まったくなし)
- 関数またはマクロの場合、その位置引数は何ですか
- docstring がある場合は、それを表示します
- どのパッケージまたはファイルから来ているのか、いつ定義されたのか
があることがわかりましたが(documentation '_symbol_ '_type_)
、それはまさに私が必要としているものではありません。を使用する前に、シンボルがバインドされている値の型 ( 'function
、'variable
、'compiler-macro
など) を知る必要がありますdocumentation
。次に、docstring のみを返します。シンボルが欠落しているか、シンボルを使用するには不十分である可能性があります。
たとえば、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).