如何查看common lisp函数的文档?

来源:互联网 发布:mysql查询笔试题及答案 编辑:程序博客网 时间:2024/05/17 19:59

Common Lisp有几百个函数,不可能把所有的函数用法都记得很清楚,所以就希望在编写程序时可以随时的查看函数的文档描述。

首先,我找到documentation函数,其用法是:

 (documentation 'symbol 'type)
例如,我想查看make-hash-table函数,其用法和结果如下:

CL-USER> (documentation 'make-hash-table 'function)"Create and return a new hash table. The keywords are as follows:     :TEST -- Indicates what kind of test to use.     :SIZE -- A hint as to how many elements will be put in this hash       table.     :REHASH-SIZE -- Indicates how to expand the table when it fills up.       If an integer, add space for that many elements. If a floating       point number (which must be greater than 1.0), multiply the size       by that amount.     :REHASH-THRESHOLD -- Indicates how dense the table can become before       forcing a rehash. Can be any positive number <=1, with density       approaching zero as the threshold approaches 0. Density 1 means an       average of one entry per bucket."
这个返回结果信息很好。但是,对于一些函数如random,其返回的内容就很少:

CL-USER> (documentation 'random 'function)NIL

所以,我希望找到一种可以查看任何函数的方法。


最后,我在slime的manual中找到了查看函数文档的命令:

C-c C-d hM-x slime-hyperspec-lookupLookup the symbol at point in the Common Lisp Hyperspec. This uses the familiar hyperspec.el to show the appropriate section in a web browser. The Hyperspec is found either on the Web or in common-lisp-hyperspec-root, and the browser is selected by browse-url-browser-function.Note: this is one case where C-c C-d h is not the same as C-c C-d C-h.
这个命令,默认情况下,会进行在线的查询,需要网络连接正常。为了在不方便上网的时候也可以查看函数文档,我们只需要把Hyperspec文档下载到本地,然后在文件hypersepc.el中修改变量common-lisp-hyperspec-root的值为你本地的路径(即存放Hyperspec文档的路径)。


越来越感觉,只要正确设置好,lisp的交互环境比python的交互环境更强大。




原创粉丝点击