我的以下代码片段将给出SB-INT:SIMPLE-READER-PACKAGE-ERROR; 我知道这是因为当REPL读取代码时,尚未定义包“quicklisp-quickstart”;但是软件包IS在“quicklisp.lisp”中定义。
如何使以下代码有效? 或者我如何告诉常见的lisp阅读器这个包将在动态加载的文件中定义?
* (let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(if (probe-file quicklisp-init)
(load quicklisp-init)
(progn
(load "quicklisp.lisp")
(quicklisp-quickstart:install))))
debugger invoked on a SB-INT:SIMPLE-READER-PACKAGE-ERROR in thread
#<THREAD "main thread" RUNNING {100299C6A3}>:
Package QUICKLISP-QUICKSTART does not exist.
Stream: #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDIN* {100017F893}>
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
答案 0 :(得分:6)
您可以使用FIND-SYMBOL
尝试找到该功能,并使用FUNCALL
进行调用。像
(let* ((package (find-package :quicklisp-quickstart))
(function (unless (null package)
(find-symbol (string '#:install)
package))))
(if (null function)
(error "Can't install...")
(funcall function)))