小编Don*_*ron的帖子

Common Lisp函数或用于创建临时文件名的习惯用法?

是否有Common Lisp函数或创建临时文件名或文件的典型方法?

common-lisp

10
推荐指数
2
解决办法
1408
查看次数

Common Lisp:获取宏的文档字符串

在SBCL中,我可以得到一个函数的文档字符串,如下所示:

(documentation #'mapcar t)
Run Code Online (Sandbox Code Playgroud)

但是,我不明白如何获取宏的文档字符串.例如,给定宏:

(defmacro with-lines-in-file ((line filename) &body body)
  "Runs body for each line in the file specified by filename."
  (let ((file (gensym)))
    `(with-open-file (,file ,filename)
      (do ((,line (read-line ,file nil) (read-line ,file nil)))
          ((null ,line) nil)
        ,@body))))
Run Code Online (Sandbox Code Playgroud)

我无法检索文档字符串.我不了解CLHS.如下所示,CLHS非常适合获取函数的文档字符串.

documentation (x function) (doc-type (eql 't))
Run Code Online (Sandbox Code Playgroud)

但是,从宏获取文档字符串的位似乎对我不起作用:

documentation (x symbol) (doc-type (eql 'compiler-macro))
Run Code Online (Sandbox Code Playgroud)

在我的宏的上下文中,我将上面的CLHS位解释为:

(documentation 'with-lines-in-file 'compiler-macro)
Run Code Online (Sandbox Code Playgroud)

但那个电话会回复NIL.

我正在尝试构建一个函数,为我计划在GitHub上共享的Common Lisp包创建README.md文件.这是一个例子:https://github.com/macnod/dc-utilities.我在这里写了一篇关于此的帖子:https://donnieknows.com/documenting-common-lisp-for-github/.

documentation macros common-lisp

3
推荐指数
1
解决办法
329
查看次数

标签 统计

common-lisp ×2

documentation ×1

macros ×1