如何在Common Lisp REPL中查看docstrings和其他符号信息? [英] How to see docstrings and other symbol information in Common Lisp REPL?

查看:143
本文介绍了如何在Common Lisp REPL中查看docstrings和其他符号信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对CL很新,我想学习如何阅读文档字符串,并从REPL获取其他帮助信息。例如,在Python中的帮助(符号)或iPython中的符号:t :i 在Haskell的GHCi中。



所以,给定一个符号名称'd喜欢能够知道:




  • 它绑定什么样的价值,如果有的话(一个函数,一个变量,无如果它是一个函数或一个宏,那么它的位置参数

  • 如果它有一个docstring,显示它


  • 什么包或文件来自或何时定义



我发现有(文档'_symbol_'_type _),但这不是我所需要的。我需要知道符号所绑定的值的类型('函数'变量'compiler-macro 等),然后才能使用文档。然后它只返回docstring,它可能丢失或不足以使用该符号。



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

 > (文件mapcar功能)
NIL

我希望能够看到这样做:

 >>>地图? 
类型:builtin_function_or_method
基类:< type'builtin_function_or_method'>
字符串形式:<内置函数映射>
命名空间:Python内置
Docstring:
map(function,sequence [,sequence ...]) - >列表

返回将函数应用于
的参数序列的结果列表。如果给出多个序列,
函数将被调用,其参数列表由每个序列的相应的
项组成,在没有全部
序列具有相同长度的情况下将None替换为缺失值。如果函数为None,则返回
的列表(如果有多个序列,则返回元组列表)。


解决方案

如上所述Common Lisp具有标准功能: DESCRIBE INSPECT 文档。典型的Lisp IDE也有这些绑定到键和菜单。



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



大多数IDE也有按键来显示arglist和文档。还有空间上的arglist功能。



LispWorks具体示例: LispWorks参数列表信息 LispWorks表达式菜单



我可以推荐阅读Slime,LispWorks,Allegro CL或您正在使用的任何IDE的IDE手册。


I'm completely new to CL, and I'd like to learn how to read documentation strings and get other help information from the REPL. Something like help(symbol) in Python, or symbol? in iPython, or :t and :i in Haskell's GHCi.

So, given a symbol name, I'd like to be able to know:

  • what kind of value it is bound to, if any (a function, a variable, none at all)
  • if it is a function or a macro, then what are its positional arguments
  • if it has a docstring, show it
  • what package or file it is coming from or when it was defined

I found there is (documentation '_symbol_ '_type_), but it is not exactly what I need. I need to know the type of value the symbol is bound to ('function, 'variable, 'compiler-macro, etc.) before I can use documentation. Then it returns only the docstring, it may be missing or not sufficient to use the symbol.

For example, in Lisp, the help for mapcar is not very useful (CLisp's REPL):

> (documentation 'mapcar 'function)
NIL

I'd like to be able to see something like this instead:

>>> 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).

解决方案

As mentioned Common Lisp has standard functions: DESCRIBE, INSPECT and DOCUMENTATION. Typical Lisp IDEs also have these bound to keys and menus.

For standard Common Lisp functionality most IDEs directly link to the Common Lisp HyperSpec documentation with a keystroke.

Most IDEs also have keystrokes to show the arglist and the documentation. There is also the 'arglist on space' functionality.

LispWorks specific examples: LispWorks Argument list information and LispWorks Expressions menu

I can recommend to read the IDE manual for Slime, LispWorks, Allegro CL, or whatever IDE you are using.

这篇关于如何在Common Lisp REPL中查看docstrings和其他符号信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆