我正在阅读The Complete Idiot的Common Lisp包指南,我已经创建了一个名为named BOB
using 的新包make-package
.但是之后(in-package :bob)
,我无法使用任何符号,而这些符号在" CL-USER
包装"中可以使用.例如:
CL-USER> (make-package :bob)
CL-USER> (in-package :bob)
BOB> (+ 1 2)
;; caught COMMON-LISP:STYLE-WARNING:
;; undefined function +
Run Code Online (Sandbox Code Playgroud)
我也尝试使用CL-USER
包,如下所示,但我得到了相同的结果:
CL-USER> (make-package :bob :use '(:cl-user))
Run Code Online (Sandbox Code Playgroud)
我如何使用中定义的符号CL-USER
?
Rai*_*wig 11
CL-USER
usually does not export anything. So it's useless to use it. That a package uses other packages, does not mean it exports anything. These are independent functionalities.
Since SBCL introduced an incompatibility to common practice (though not the standard), you have to specify the packages to use all the time - there is no default. Before that, there was a default (CLtL1 defined it that way). Now SBCL uses no package and this is allowed by the ANSI CL standard.
If you want a package with a use list like CL-USER, do this instead:
CL-USER 1 > (package-use-list "CL-USER")
(#<The COMMON-LISP package, 2/4 internal, 978/1024 external>
#<The HARLEQUIN-COMMON-LISP package, 3/4 internal, 271/512 external>
#<The LISPWORKS package, 67/128 internal, 228/256 external>)
CL-USER 2 > (make-package "FOO" :use (package-use-list "CL-USER"))
#<The FOO package, 0/16 internal, 0/16 external>
CL-USER 3 > (in-package "FOO")
#<The FOO package, 0/16 internal, 0/16 external>
FOO 4 > (+ 3 4)
7
Run Code Online (Sandbox Code Playgroud)