如何使用quicklisp安装的软件包? [英] How to use packages installed by quicklisp?

查看:102
本文介绍了如何使用quicklisp安装的软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用quicklisp安装了CL-PNG软件包.

I've installed the CL-PNG package using quicklisp.

(ql:quicklisp 'png)

现在,我想定义自己的依赖于CL-PNG软件包的软件包.像这样:

Now I want to define my own package which depends on the CL-PNG package. Like so:

(defpackage :FOO
  (:use :CL :PNG)
  (:export :BAR))

编译时出现此错误:

The name "PNG" does not designate any package.
   [Condition of type SB-KERNEL:SIMPLE-PACKAGE-ERROR]

似乎我在编译程序包之前必须在REPL上调用(require :PNG).

It seems that I have to call (require :PNG) on the REPL before compiling my package.

我如何做才能使CL-PNG软件包对编译器可用,而无需在REPL上手动调用require?

What do I have to do to make the CL-PNG package available for the compiler without manually call require on the REPL?

更新:我正在使用SBCL.

UPDATE: I'm using SBCL.

推荐答案

您混淆了两个单独的概念:systempackage. package由Common Lisp标准定义,它是符号的集合,是控制其可见性和用法的一种方式. system不是由标准定义的,它是由ASDF引入的一个概念,该概念是元数据的集合,用于管理单个项目中的文件相互依赖关系,以便能够正确地编译和加载它. Quicklisp建立在ASDF的基础上,提供了一种分发项目的方式,以ASDF system s的形式描述.

You confuse two separate notions: a system and a package. A package is defined by Common Lisp standard and it's a collection of symbols, a way to control their visibility and usage. A system is not defined by the standard, it's a notion introduced by ASDF, which is a collection of metadata to manage files inter-dependencies in a single project in order to be able to properly compile and load it. Quicklisp is built on top of ASDF to provide a way to distribute projects, described in the form of ASDF systems.

因此,当您安装(quickload)一个名为PNGsystem时,这并不意味着该系统具有一个名为PNG的软件包.系统是否定义了任何程序包(通常定义了一个程序包,甚至定义了几个程序包),如何调用它们由其作者决定.大多数项目将具有package.lisppackages.lisp文件,其中定义了它们的package.

So when you install (quickload) a system, called PNG, this doesn't mean, that this system has a package, called PNG. Does the system define any packages (usually it defines one, or even several of them) and how they are called is at the discretion of its author. Most of the projects will have package.lisp or packages.lisp files, where their packages are defined.

但是对于正在加载的CL-PNG系统,它实际上定义了软件包PNG,并且在您运行quickload之后它应该在运行的进程中可用.但是,每次启动Lisp系统时,都应该以某种方式加载它. ASDF提供了一种定义对CL-PNG系统的依赖关系的方法,因此您只能加载自己的 system,并且依赖它的所有system都将被加载自动,使您要使用的所有package都可用.

But in the case of CL-PNG system you're loading, it actually defines the package PNG, and it should be available in the running process after you quickload it. But you should somehow load it every time you start your Lisp system. ASDF provides a means to define a dependency on CL-PNG system, so that you can just load only your own system, and all of the systems it depends on will be loaded automatically, making available all packages you want to use.

这篇关于如何使用quicklisp安装的软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆