我在 SBCL 中使用“pregexp”包进行正则表达式操作。因为函数没有在包中定义,所以我有下面的代码来包装它:
--------------- 在文件“foo.lisp”中 -----------------
(defpackage :pregexp
(:use :common-lisp)
(:documentation "Portable Regular Expression Library")
(:nicknames :pre))
(in-package :pregexp)
(load (merge-pathnames "libs/pregexp/pregexp" CL-USER:*x-code-path*))
(export '(pregexp
pregexp-match-positions
pregexp-match
pregexp-split
pregexp-replace
pregexp-replace*
pregexp-quote))
我将代码放在初始化文件“~/.sbclrc”中,以在启动时加载“foo.lisp”。现在一切正常,当我启动 SBCL 时没有错误。
然后我注意到每次重新加载“foo.lisp”时,都有警告说函数已经导出,所以我更改了代码:
--------------- 在文件“foo.lisp”中 -----------------
#-pregexp
(progn
(defpackage :pregexp
(:use :common-lisp)
(:documentation "Portable Regular Expression Library")
(:nicknames :pre))
(in-package :pregexp)
(load (merge-pathnames "libs/pregexp/pregexp" CL-USER:*x-code-path*))
(export '(pregexp
pregexp-match-positions
pregexp-match
pregexp-split
pregexp-replace
pregexp-replace*
pregexp-quote))
(pushnew :pregexp *features*)
)
我只将代码包装在“progn”块中,但每次启动 SBCL 时,都会出现错误:
debugger invoked on a SB-KERNEL:SIMPLE-PACKAGE-ERROR in thread
#<THREAD "main thread" RUNNING {23EF7A51}>:
These symbols are not accessible in the PREGEXP package:
(COMMON-LISP-USER::PREGEXP COMMON-LISP-USER::PREGEXP-MATCH-POSITIONS
COMMON-LISP-USER::PREGEXP-MATCH COMMON-LISP-USER::PREGEXP-SPLIT
COMMON-LISP-USER::PREGEXP-REPLACE COMMON-LISP-USER::PREGEXP-REPLACE*
COMMON-LISP-USER::PREGEXP-QUOTE)
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [CONTINUE] IMPORT these symbols into the PREGEXP package.
1: [RETRY ] Retry EVAL of current toplevel form.
2: Ignore error and continue loading file "C:\\test\\bar.lisp".
3: [ABORT ] Abort loading file "C:\\test\\bar.lisp".
4: Retry EVAL of current toplevel form.
5: Ignore error and continue userinit file "C:\\user\\Dropbox\\.sbclrc".
6: Abort userinit file "C:\\user\\Dropbox\\.sbclrc".
7: Skip to toplevel READ/EVAL/PRINT loop.
8: [EXIT ] Exit SBCL (calling #'EXIT, killing the process).
((FLET SB-IMPL::THUNK :IN EXPORT))
0]
那么,我现在该怎么办?
PS,环境:SBCL x86 1.1.4 On Windows Server 2003 32bits