closure-common: sbcl borks 因为标准的可读表被修改

closure-common: sbcl borks because standard readtable modified

我将 quicklisp 更新到 2 月的最新版本,并重新运行 我正在开发的 xlmanip workbook/worksheet reader 的一些单元测试. SBCL 在单元测试中失败,因为它重新编译了 closure-common 包并且 closure-common 修改了标准可读表(实际上以一种很好的方式。)

我的一个选择是 fork closure-common 代码库,希望维护者真正响应补丁,并祈祷补丁被接受,follow clozure-common dependencies in quicklisp where SET-DISPATCH-MACRO-CHARACTER 也出于同样的原因被调用。

有人知道这个问题的解决方法吗? closure-common 不是唯一有这个问题的软件包,我很确定。

编辑:如果我必须克隆和修改 clozure-common,recommended/preferred 本地化可读表修改或切换到自定义可读表的方法是什么?

编辑 #2:这是使用新安装的 quicklisp 的输出记录(具体来说,查看 closure-common-20101107-git/syntax.lisp 的最后一行,其中调用了 SET-DISPATCH-MACRO-CHARACTER):

To load "xlmanip/tests":
  Load 1 ASDF system:
    xlmanip/tests
; Loading "xlmanip/tests"
.
;;; Checking for wide character support... WARNING: Lisp implementation doesn't use UTF-16, but accepts surrogate code points.
 yes, using code points.
..
;;; Checking for wide character support... WARNING: Lisp implementation doesn't use UTF-16, but accepts surrogate code points.
 yes, using code points.
;;; Building Closure with CHARACTER RUNES
........While evaluating the form starting at line 4, column 0
  of #P"/tmp/xlmanip17497a.lisp":
Fatal condition:
SET-DISPATCH-MACRO-CHARACTER would modify the standard readtable.
See also:
  The ANSI Standard, Section 2.1.1.2
  The ANSI Standard, Glossary entry for "standard readtable"
Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1002A7D263}>
0: ((LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX))
1: (SB-IMPL::CALL-WITH-SANE-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX) {1006B1F8BB}>)
2: (SB-IMPL::%WITH-STANDARD-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX) {1006B1F88B}>)
3: (SB-DEBUG:PRINT-BACKTRACE :STREAM #<SB-SYS:FD-STREAM for "standard error" {1003135713}> :START 0 :FROM :DEBUGGER-FRAME :COUNT 4611686018427387903 :PRINT-THREAD T :PRINT-FRAME-SOURCE NIL :METHOD-FRAME-STYLE NIL :EMERGENCY-BEST-EFFORT NIL)
4: ((LAMBDA NIL :IN UIOP/IMAGE:PRINT-BACKTRACE))
5: ((LAMBDA NIL :IN UIOP/STREAM:CALL-WITH-SAFE-IO-SYNTAX))
6: (SB-IMPL::%WITH-STANDARD-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN UIOP/STREAM:CALL-WITH-SAFE-IO-SYNTAX) {1006B1F86B}>)
7: (UIOP/IMAGE:PRINT-CONDITION-BACKTRACE #<SB-INT:STANDARD-READTABLE-MODIFIED-ERROR {1006B1D643}> :STREAM #<SB-SYS:FD-STREAM for "standard error" {1003135713}> :COUNT NIL)
8: (UIOP/IMAGE:HANDLE-FATAL-CONDITION #<SB-INT:STANDARD-READTABLE-MODIFIED-ERROR {1006B1D643}>)
9: (SIGNAL #<SB-INT:STANDARD-READTABLE-MODIFIED-ERROR {1006B1D643}>)
10: (CERROR "Frob it anyway!" SB-INT:STANDARD-READTABLE-MODIFIED-ERROR :OPERATION SET-DISPATCH-MACRO-CHARACTER)
11: (SET-DISPATCH-MACRO-CHARACTER #\# #\/ RUNES::RUNE-READER #<READTABLE {100041EA83}>)
12: (SB-FASL::LOAD-FASL-GROUP #S(SB-FASL::FASL-INPUT :STREAM #<SB-SYS:FD-STREAM for "file <homedir>/.cache/common-lisp/sbcl-1.3.1.243-55a6786-macosx-x64/<homedir>/quicklisp/dists/quicklisp/software/closure-common-20101107-git/syntax.fasl" {1006B0F693}> :TABLE #(282 SET *PACKAGE* "RUNES" #<PACKAGE "SB-IMPL"> SB-IMPL::%DEFUN #<PACKAGE "RUNES"> RUNES::RT-WHITE-SPACE-P STRING MAKE-STRING-INPUT-STREAM :EOF PEEK-CHAR ...) :STACK #(0 SET-DISPATCH-MACRO-CHARACTER #\# #\/ RUNES::RUNE-READER 0 50 "<homedir>/quicklisp/dists/quicklisp/software/closure-common-20101107-git/syntax.lisp" #<SB-KERNEL:LAYOUT for SB-C:DEFINITION-SOURCE-LOCATION {10000415B3}> NIL NIL NIL ...) :DEPRECATED-STUFF NIL :SKIP-UNTIL NIL) NIL)
<...truncated... error occurs in syntax.lisp>

生成此输出的脚本:

#!/bin/sh

tmpf=/tmp/xlmanip$$a.lisp
cat >${tmpf} <<__EOF__
(proclaim '(optimize speed space))
;;; SBCL:Muffle compiler-notes
#+sbcl (declaim (sb-ext:muffle-conditions sb-ext:compiler-note))
(ql:quickload :xlmanip/tests)
(time (asdf:oos 'asdf:test-op :xlmanip))
(quit)
__EOF__

trap "rm -f ${tmpf}" 0 1 2 3 15

if test "x${CL_LISPS}" = x; then
  CL_LISPS="sbcl ccl clisp ecl"
fi

for l in $CL_LISPS; do
  echo "\n======== $l ========\n"
  cl-launch --lisp $l --execute --quicklisp --init '(load "'"${tmpf}"'")'
done

诊断问题:在加载closure-common的代码流中某处,似乎有一个调用类似于:

(with-standard-io-syntax
  (load "closure-common"))

这是我发现的使标准 *readtable* 修改失效的唯一方法。在所有其他情况下,例如,在 sbcl 提示符下,set-dispatch-macro-character 不会修改标准 *readtable*。我没有将问题追溯到 ASDF、UIOP 或 Quicklisp 本身,尽管它们也可能是候选对象。

我硬着头皮克隆了闭包公共存储库并决定使用 named-readtables。很可能,如果我将这些更改发布到 quicklisp,隐含地获得维护权,那么其他使用 #"#/ reader 宏的依赖包将发生涟漪变化 reader closure-common.