Documentation 如何在Common Lisp REPL中查看文档字符串和其他符号信息?

Documentation 如何在Common Lisp REPL中查看文档字符串和其他符号信息?,documentation,lisp,common-lisp,read-eval-print-loop,Documentation,Lisp,Common Lisp,Read Eval Print Loop,我是CL的新手,我想学习如何阅读文档字符串并从REPL获取其他帮助信息。类似于Python中的help(symbol),或者iPython中的symbol?,或者Haskell的GHCi中的:t和:i 因此,给定一个符号名,我想知道: 它绑定到什么类型的值(如果有的话)(一个函数,一个变量,一个都没有) 如果它是函数或宏,那么它的位置参数是什么 如果它有docstring,则显示它 它来自哪个包或文件,或者是在什么时候定义的 我发现有(文档“\u symbol\uu”\u type”,但它并

我是CL的新手,我想学习如何阅读文档字符串并从REPL获取其他帮助信息。类似于Python中的
help(symbol)
,或者iPython中的
symbol?
,或者Haskell的GHCi中的
:t
:i

因此,给定一个符号名,我想知道:

  • 它绑定到什么类型的值(如果有的话)(一个函数,一个变量,一个都没有)
  • 如果它是函数或宏,那么它的位置参数是什么
  • 如果它有docstring,则显示它
  • 它来自哪个包或文件,或者是在什么时候定义的
我发现有
(文档“\u symbol\uu”\u type”
,但它并不完全是我需要的。我需要知道符号绑定到的值的类型(
函数
变量
编译器宏
,等等),然后才能使用
文档
。然后它只返回docstring,它可能丢失或不足以使用符号

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

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

>>> 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).
地图? 类型:内置函数或方法 基类: 字符串形式: 名称空间:Python内置 文档字符串: 映射(函数,序列[,序列,…])->列表 返回将函数应用于以下项的结果列表: 参数序列。如果给出了多个序列,则 函数调用时使用由相应 每个序列的项,如果不是全部,则用“无”替换缺失的值 序列具有相同的长度。如果函数为None,则返回 序列的项(如果有多个序列,则为元组列表)。
如前所述,通用Lisp具有标准函数:、和。典型的LispIDE也将这些绑定到键和菜单

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

大多数IDE也有按键来显示arglist和文档。还有“arglist on space”功能

LispWorks特定示例:和


我建议您阅读、或您正在使用的任何IDE的IDE手册。

关于获取符号类型的问题:没有这样的东西。或者,更准确地说,符号不仅是其他对象的名称,而且本身也是该类型的对象。每个符号都可以有一个变量值和一个函数值。要检查它是否有变量值,请使用,并检查函数值。

您使用的编译器是什么?在我的CL中,
(文档'mapcar'函数)
给出:“将函数应用于列表的连续元素。返回函数返回值列表。”
(检查'mapcar)
(描述'mapcar)
可能是您要查找的,虽然这些函数的实际效用在很大程度上取决于特定的实现。公平地说,所有函数的效用在很大程度上取决于实现。:-)谢谢你,丹尼尔。事实上,
inspect
description
正是我想要的。非常感谢。如果你把它作为答案写下来,我可以接受@肯:我安装了CLisp和SBCL,但到目前为止我主要使用CLisp(它的readline-enabled REPL对我来说要好得多)。SBCL的docstring确实有用得多,但它仍然只是一个docstring(仍然需要以某种方式找到符号类型和参数列表)。好的,通过@Rainer接受答案。谢谢。我知道符号可以解除绑定。了解
boundp
fboundp
非常有用<代码>描述似乎足够交互使用。
>>> 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).