ltk(common lisp)的问题

发布于 2024-08-25 02:02:20 字数 1281 浏览 7 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

难以启齿的温柔 2024-09-01 02:02:21

您必须将符号导入到您希望其工作的包中。

通用的“user”包是cl-user,并且“原始”图像会将您带到那里。为了从另一个包导入(导出的)符号,请发出 (use-package :another-package)。 REPL 示例:

(asdf:load-system :ltk)
(use-package :ltk)

有时想要使用未导入的符号。然后,您可以使用包作为它们的前缀,例如 bar:foo,其中 bar 是包名称,foo 是符号。

在实际系统上工作时,您通常会为其定义一个或多个包。这是通过 defpackage 完成的,您可以直接告诉要导入哪些其他包:

(defpackage #:my-app
  (:use :cl
        :ltk))

然后,您需要切换到该包:

(in-package #:my-app)

当设置具有多个相互依赖的文件的更复杂的系统时,系统定义工具变得值得。目前最广泛使用的是 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:

(asdf:load-system :ltk)
(use-package :ltk)

Sometimes one wants to use symbols that are not imported. You can then prefix them with the package, like bar:foo, where bar is the package name and foo 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:

(defpackage #:my-app
  (:use :cl
        :ltk))

Then, you need to switch to that package:

(in-package #:my-app)

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.

才能让你更想念 2024-09-01 02:02:21

ASDF 不会将包加载到 COMMON-LISP-USER 包中。因此,WITH-LTK 未在您当前的包中定义,因此您需要执行以下操作:

(asdf:oos 'asdf:load-op :ltk)
(in-package :ltk)
;put your function here

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:

(asdf:oos 'asdf:load-op :ltk)
(in-package :ltk)
;put your function here
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文