如何查看defparameter,defconstant或defvar的doc字符串?

anq*_*egi 5 sbcl common-lisp

使用常见的lisp你可以添加许多文档字符串,例如:

CL-USER> (defun foo ()
           "doc string for foo"
           nil)
FOO
CL-USER> (documentation 'foo 'function)
"doc string for foo"

CL-USER> (describe 'foo)
COMMON-LISP-USER::FOO
  [symbol]

FOO names a compiled function:
  Lambda-list: ()
  Derived type: (FUNCTION NIL (VALUES NULL &OPTIONAL))
  Documentation:
    doc string for foo
  Source form:
    (SB-INT:NAMED-LAMBDA FOO
        NIL
      "doc string for foo"
      (BLOCK FOO NIL))
; No value
Run Code Online (Sandbox Code Playgroud)

所以最后我可以读回文档字符串,但是使用符号和变量我无法通过文档获取它:

CL-USER> (defparameter bar 3 "doc string for bar")
BAR
CL-USER> (describe 'bar)
COMMON-LISP-USER::BAR
  [symbol]

BAR names a special variable:
  Value: 3
  Documentation:
    doc string for bar
; No value
CL-USER> (documentation 'bar 'symbol)
WARNING: unsupported DOCUMENTATION: doc-type SYMBOL for object of type SYMBOL
NIL
Run Code Online (Sandbox Code Playgroud)

因此,类型符号或我将使用的类型是错误的.我不确定到底发生了什么

我正在使用:SBCL 1.3.10

cor*_*ump 10

我们来看看文档documentation;-)

CL-USER> (documentation 'documentation 'function)
"Return the documentation string of Doc-Type for X, or NIL if none
exists. System doc-types are VARIABLE, FUNCTION, STRUCTURE, TYPE, SETF, and T.
[...]"
Run Code Online (Sandbox Code Playgroud)

所以:

CL-USER> (documentation 'bar 'variable)
"doc string for bar"
Run Code Online (Sandbox Code Playgroud)

详情documentation请见.