ltk(common lisp)的问题
我使用 asdf-install 将 ltk 安装到 Steel Bank Common Lisp,但我什至无法开始使用它 V_V。下面的代码是文档中最简单的示例,几乎是逐字复制的。
(asdf:operate 'asdf:load-op :ltk)
(defun hello-1()
(with-ltk ()
(let ((b (make-instance 'button
:master nil
:text "Press Me"
:command (lambda ()
(format t "Hello World!~&")))))
(pack b))))
(hello-1)
这是我从 sbcl 收到的错误消息:
> ; in: LAMBDA NIL
; (PACK B)
;
; caught STYLE-WARNING:
; undefined function: PACK
; (WITH-LTK NIL
; (LET ((B (MAKE-INSTANCE 'BUTTON :MASTER NIL :TEXT "Press Me" :COMMAND #)))
; (PACK B)))
;
; caught STYLE-WARNING:
; undefined function: WITH-LTK
;
; compilation unit finished
; Undefined functions:
; PACK WITH-LTK
; caught 2 STYLE-WARNING conditions
debugger invoked on a SIMPLE-ERROR in thread #<THREAD "initial thread" RUNNING {1002A57B61}>:
There is no class named BUTTON.
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
(SB-PCL::FIND-CLASS-FROM-CELL BUTTON NIL T)
I installed ltk to Steel Bank Common Lisp with asdf-install, but I can't even start using it V_V. The code below is the simplest example in the documentation, and is copied almost verbatim.
(asdf:operate 'asdf:load-op :ltk)
(defun hello-1()
(with-ltk ()
(let ((b (make-instance 'button
:master nil
:text "Press Me"
:command (lambda ()
(format t "Hello World!~&")))))
(pack b))))
(hello-1)
This is the error message I get from sbcl:
> ; in: LAMBDA NIL
; (PACK B)
;
; caught STYLE-WARNING:
; undefined function: PACK
; (WITH-LTK NIL
; (LET ((B (MAKE-INSTANCE 'BUTTON :MASTER NIL :TEXT "Press Me" :COMMAND #)))
; (PACK B)))
;
; caught STYLE-WARNING:
; undefined function: WITH-LTK
;
; compilation unit finished
; Undefined functions:
; PACK WITH-LTK
; caught 2 STYLE-WARNING conditions
debugger invoked on a SIMPLE-ERROR in thread #<THREAD "initial thread" RUNNING {1002A57B61}>:
There is no class named BUTTON.
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
(SB-PCL::FIND-CLASS-FROM-CELL BUTTON NIL T)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须将符号导入到您希望其工作的包中。
通用的“user”包是
cl-user
,并且“原始”图像会将您带到那里。为了从另一个包导入(导出的)符号,请发出(use-package :another-package)
。 REPL 示例:有时想要使用未导入的符号。然后,您可以使用包作为它们的前缀,例如
bar:foo
,其中bar
是包名称,foo
是符号。在实际系统上工作时,您通常会为其定义一个或多个包。这是通过 defpackage 完成的,您可以直接告诉要导入哪些其他包:
然后,您需要切换到该包:
当设置具有多个相互依赖的文件的更复杂的系统时,系统定义工具变得值得。目前最广泛使用的是 ASDF,尽管存在一些替代方案。
You have to import the symbols into the package you want it to work in.
The generic "user" package is
cl-user
, and a "virgin" image will put you there. In order to import the (exported) symbols from another package, issue(use-package :another-package)
. Example on the REPL:Sometimes one wants to use symbols that are not imported. You can then prefix them with the package, like
bar:foo
, wherebar
is the package name andfoo
the symbol.When working on a real system, you will usually define one or more packages for it. This is done through
defpackage
, which you can tell what other packages to import directly:Then, you need to switch to that package:
When setting up a more complicated system with several interdependent files, a system definition facility becomes worthwhile. The currently most widely used is ASDF, although a handful of alternatives exist.
ASDF 不会将包加载到 COMMON-LISP-USER 包中。因此,WITH-LTK 未在您当前的包中定义,因此您需要执行以下操作:
ASDF doesn't load a package into the COMMON-LISP-USER package. As a result, WITH-LTK isn't defined in your current package, so you need to do this: