Reputation: 159
My following code snippets will give SB-INT:SIMPLE-READER-PACKAGE-ERROR; I know it is because package "quicklisp-quickstart" is not defined yet while REPL reads the code; But the package IS defined in "quicklisp.lisp".
How can I make the following code work? Or How can I tell the common lisp reader this package will be defined in the dynamically loaded file?
* (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.
Upvotes: 2
Views: 381
Reputation: 8411
You can use FIND-SYMBOL
to try and find the function, and call it with FUNCALL
. Something like
(let* ((package (find-package :quicklisp-quickstart))
(function (unless (null package)
(find-symbol (string '#:install)
package))))
(if (null function)
(error "Can't install...")
(funcall function)))
Upvotes: 6