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

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

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

  • 我发现这里有(documentation '_symbol_ '_type_),但这并不是我真正需要的。我需要知道符号绑定(bind)到的值的类型('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).
    

    最佳答案

    如前所述,Common Lisp具有标准功能:DESCRIBEINSPECTDOCUMENTATION。典型的Lisp IDE也将这些绑定(bind)到键和菜单。

    对于标准的Common Lisp功能,大多数IDE都可以通过按键直接链接到Common Lisp HyperSpec文档。

    大多数IDE都有击键来显示arglist和文档。还有“太空arglist”功能。

    LispWorks的特定示例:LispWorks Argument list informationLispWorks Expressions menu

    我可以建议阅读SlimeLispWorks EditorAllegro CL's ELI或所用任何IDE的IDE手册。

    关于documentation - 如何在Common Lisp REPL中查看文档字符串和其他符号信息?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5093513/

    10-12 07:33
    查看更多