如何使用quicklisp加载外部依赖项?(How to load external dependencies with quicklisp?)

系统教程 行业动态 更新时间:2024-06-14 17:01:31
如何使用quicklisp加载外部依赖项?(How to load external dependencies with quicklisp?)

这是我的代码:

(defpackage :com.yves.tests (:use :common-lisp)) (in-package :com.yves.tests) (require :usocket)

每次我评估require指令时,都会收到此错误:

LOAD: A file with name #1=USOCKET does not exist [Condition of type SYSTEM::SIMPLE-FILE-ERROR]

当然我在我的REPL中使用quickload安装了包:

CL-USER> (ql:quickload "usocket") To load "usocket": Load 1 ASDF system: usocket ; Loading "usocket" ("usocket") CL-USER>

实际上我昨天晚上安装了它,我的所有代码都在评估,没有抱怨。 今天我重温了Emacs和史莱姆。 我得到了这个错误。 还有其他配置要做吗?

这是我的加载路径中的内容:

CL-USER> (princ custom:*load-paths*) (/Users/yves/quicklisp/ /opt/local/lib/clisp-2.49/dynmod/ ./ ~/lisp/**/) (#P"/Users/yves/quicklisp/" #P"/opt/local/lib/clisp-2.49/dynmod/" #P"./" "~/lisp/**/") CL-USER>

我应该手动添加每个新包装的路径吗? 是不是quicklisp初始化应该执行它本身?

Here is my code:

(defpackage :com.yves.tests (:use :common-lisp)) (in-package :com.yves.tests) (require :usocket)

Everytime I evaluate the require directive, I get this error:

LOAD: A file with name #1=USOCKET does not exist [Condition of type SYSTEM::SIMPLE-FILE-ERROR]

Of course I installed the package with quickload in my REPL:

CL-USER> (ql:quickload "usocket") To load "usocket": Load 1 ASDF system: usocket ; Loading "usocket" ("usocket") CL-USER>

Actually I've installed it yesterday evening, and all my code was evaluating with no complain. Today I restarded Emacs and Slime. And I get this error. Is there additional configuration to do?

Here is what is in my loadpath:

CL-USER> (princ custom:*load-paths*) (/Users/yves/quicklisp/ /opt/local/lib/clisp-2.49/dynmod/ ./ ~/lisp/**/) (#P"/Users/yves/quicklisp/" #P"/opt/local/lib/clisp-2.49/dynmod/" #P"./" "~/lisp/**/") CL-USER>

Am I supposed to add the path to every new package by hand? Isn't quicklisp initialisation supposed to perform it, by itself?

最满意答案

Require不是此处所需的操作。

在简单的情况下,您将整个系统放在一个自给自足的文件中,您可以将ql:quickload表单包装到eval-when :

(in-package #:cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (ql:quickload "usocket")) (defpackage #:com.yves.tests (:use #:cl)) (in-package #:com.yves.tests) ;; your code here

如果您想在没有限定usocket情况下使用来自usocket符号, usocket在defpackage表单中使用它:

(defpackage #:com.yves.tests (:use #:cl #:usocket))

如果您有一个跨越多个文件的更大系统,则可以使用ASDF。 快速项目是一种快速实现简单设置的quickproject ,也可以从Quicklisp获得。

Require is not the required operation here.

In the simple case where you have your entire system in one self-sufficient file, you can wrap ql:quickload forms into an eval-when:

(in-package #:cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (ql:quickload "usocket")) (defpackage #:com.yves.tests (:use #:cl)) (in-package #:com.yves.tests) ;; your code here

If you want to use symbols from usocket without qualification, use it in the defpackage form:

(defpackage #:com.yves.tests (:use #:cl #:usocket))

If you have a bigger system that spans several files, you can use ASDF. A quick way to get a simple setup running is quickproject, also available from Quicklisp.

更多推荐

本文发布于:2023-04-20 16:12:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/f2fd9902e5ce99500c70c231af12aba4.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   加载   quicklisp   dependencies   load

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!