我已经编写了Scheme表达式注释(SRFI 62)的Common Lisp实现:
(eval-when (:compile-toplevel
:load-toplevel
:execute)
(set-dispatch-macro-character #\# #\;
(lambda (stream char n)
(declare (ignore char))
(when n
(error "Infix parameter not allowed in s-expression comment."))
(read stream) ; Discard the s-expression.
(values))))根据我对The RECURSIVE-P argument的阅读,我的实现似乎是不正确的。我必须改为使用(read stream t nil t) (即将recursive-p参数设置为t)。我的理解正确吗?
我一直在使用上面明显不正确的实现,它似乎运行正常。如果我继续使用(read stream)而不是(read stream t nil t),会发生什么?
发布于 2021-09-20 06:48:36
作为一个不正确行为的例子,让我们考虑RECURSIVE-P argument documentation中给出的三个原因中的第一个。首先,使用您的原始定义:
* (+ 1 #1=2 #;(+ #1# 3))
Reader error: Missing #1# label.将(read stream)更改为(read string t nil t)会得到正确的结果:
* (+ 1 #1=2 #;(+ #1# 3))
3https://stackoverflow.com/questions/69248229
复制相似问题