这是背景故事,如果您不在乎而只想看问题,请跳到底部。
我已经在 LISP 中玩了一段时间了。 一些基本函数,一些类,还有文件IO。 当我遇到这篇文章时:
http://www.adampetersen.se/articles/lispweb.htm< /a>
我很高兴尝试将 Lisp 用于 Web 应用程序。 我去下载了这些软件包,但我始终不知道如何将它们加载到我的 Allegro IDE 中。
嗯...好吧,hunchentoot 网站说很多基本包都在 LispWorks 中。 所以我下载了它。 仍然不确定如何获取我下载到这些 IDE 中的包的源代码。 他们似乎有软件包的二进制文件?
哦,好吧,也许我会切换到我的 ubuntu 服务器并 apt-get 所有软件包并设置 slime(我以前没有使用过它,因为我只是想学习 lisp。同时学习 emacs 和 lisp 似乎真的令人畏惧)。 我很容易获得所需的所有软件包并加载粘液,但同样的问题仍然不可用。
我进一步挖掘,发现了这个名为 ASDF 的程序。 看起来 ASDF 是某种 lisp 的包生成器? 我不知道这看起来很混乱。 此时我正准备放弃。
如果您仍在阅读本文,这就是我的问题。
1. 如何将这些包的源代码加载到我的 lisp 环境中。 尝试学习 lisp 并不太难,但有关环境的信息却很少。 我是否需要构建使用 ASDF 下载的软件包。
2. 有没有一种简单的方法可以让人们在 lisp 中上手并运行,而不必提前花大量时间学习所有工具?
Here is the back story skip to the bottom if you do not care and only want to see the question.
So I have been playing around in LISP for a little while. Some basic functions, some classes ,and file IO. When I run across this article:
http://www.adampetersen.se/articles/lispweb.htm
And I am excited to try and use lisp for a web application. I go and download the packages, but for the life of me do not know how to load them into my Allegro IDE.
Hmm... ok, well the hunchentoot site says a lot of the basic packages are in LispWorks. So I download that. Still not sure how to get the source for the packages that I downloaded into these IDEs. They seem to have binaries of the packages?
Oh well maybe ill switch to my ubuntu server and apt-get all the packages and setup slime (i have not used it before because I just wanted to learn lisp. Learning emacs and lisp at the same time seemed real daunting). I apt get all the packages needed and load up slime and again same problem there aren't available.
I dig around some more and see this program called ASDF. It looks like ASDF is some kind of package builder for lisp? I don't know it seems confusing. I'm about to give up at this point.
If you are still reading this here is my question.
1. How do I load the source for these packages into my lisp environment. trying to learn lisp hasn't been too hard but the information about the environments has been sparse. Do I need to build the packages I download with ASDF.
2. Is there a simple way for someone to just get up and running in lisp without having to speed a large amount of time upfront learning all the tools?
发布评论
评论(4)
这仅仅意味着作者在 Hunchentoot 中编写了很多 Lispworks 专用的代码。 这并不意味着 Hunchentoot 只能在 Lispworks 上运行。
您需要使用 ASDF。
那不太可能。
那就别这么做了。 您不需要使用 Emacs 或 Slime。
要快速获得结果,请尝试 clbuild: http://common-lisp.net/project/clbuild/
ASDF 有点像 Common Lisp 应用程序的 Makefile。
这是你能做的最糟糕的事情(在此时或任何其他时刻)。 我很高兴您决定在这里发布您的问题。
clbuild 应该为您提供所需的一切,但如果您不想使用它,这里有一些提示:
(require :asdf)
。 Lispworks、Allegro:需要下载并加载 ASDF。 将 asdf.lisp 保存在某处,然后运行 (load "/path/to/asdf.lisp")
。(push "/path/to/dir/" asdf:*central-registry*)
。 不要忘记结尾的斜杠。(asdf:oos 'asdf:load-op :system-name)
加载系统。参见上文——使用 clbuild。
This just means that the author has written a lot of Lispworks-specific code in Hunchentoot. It does not mean that Hunchentoot only works on Lispworks.
You need to use ASDF.
That's unlikely.
Don't do it then. You don't need to use Emacs or Slime.
For quick results try clbuild: http://common-lisp.net/project/clbuild/
ASDF is a bit like a Makefile for Common Lisp applications.
That's about the worst thing you could so (at this or any other point). I'm glad you have decided to post your problems here instead.
clbuild should give you all you need, but here are some hints if you don't want to use it:
(require :asdf)
. Lispworks, Allegro: you need to download and load ASDF. Save asdf.lisp somewhere then run(load "/path/to/asdf.lisp")
.(push "/path/to/dir/" asdf:*central-registry*)
. Don't forget the trailing slash.(asdf:oos 'asdf:load-op :system-name)
.See above -- use clbuild.
Ubuntu 中最快的方法是使用该发行版中包含的软件包。 如果您只是想尝试一些东西,这是“可以的”,但这些版本通常比较旧。 我推荐包
sbcl
和slime
。 如果您还不了解 emacs,您可以通过其内置教程快速入门 (Ch t
(按 Control-h,松开,然后按 t))。然后,您可以启动 emacs,启动 slime(通过
Mx slime
),打开一个 lisp 文件 (Cx Cf ~/lisp/first-try.lisp
),然后您就可以了准备好出发。 作为 Lisp 教程,我认为《Practical Common Lisp》是一本非常好的书,而且是免费提供的。现在,当您开始喜欢 Lisp 时,您可能需要更多最新的软件包。 我建议使用 clbuild (请参阅链接以获取更多信息,包括常见问题解答)。 然后,您还可以构建一个新的 sbcl(由发行版版本引导)。
顺便说一下,ASDF 只是一个系统定义工具。 它不知道如何下载软件包,它只知道如何将系统加载到正在运行的 Lisp 镜像中。 换句话说,它只是解决按正确顺序自动加载某些“系统”(库)所组成的多个文件的问题。 最新版本允许使用简单的方式加载包(安装后,例如通过 clbuild) 旧
版本显示了 ASDF 的内部操作概念:
上面的
load-sys
是这个常见用例的简写。 更多信息(可以说,您需要了解的所有信息)位于 ASDF入门指南。 ASDF 也包含在 SBCL 中。当您加载源文件时,它会自动编译(生成
.fasl
文件(快速加载)),以便下次加载速度更快。The quickest way in Ubuntu is to use the packages included in that distribution. It is "ok" if you just want to try some things, but these versions are often comparatively old. I would recommend the packages
sbcl
andslime
. If you don't know emacs yet, you can get into that quite fast through its built-in tutorial (C-h t
(press Control-h, release, then press t)).You can then start emacs, start slime (through
M-x slime
), open a lisp file (C-x C-f ~/lisp/first-try.lisp
), and you're ready to go. As a tutorial for Lisp, I think that Practical Common Lisp is a very nice book, and it's freely available.Now, when you have come to like Lisp, you might want more up to date packages. I would recommend to use clbuild for that (see the link for further information, including FAQ). You can then also build a new sbcl (bootstrapped by the distribution's version).
ASDF, by the way, is only a system definition facility. It doesn't know how to download packages, it only knows how to load systems into a running Lisp image. In other words, it just solves the problem of automatically loading the multiple files that some "system" (library) consists of in the right order. The newest versions allow loading a package (after it is installed, e.g. through clbuild) with a simple
Older versions show ASDF's internal concept of operations:
The above
load-sys
is a shorthand for this common use case. Further information (one could say, all you need to know about it) is at the ASDF Getting Started guide. ASDF is also included in SBCL.When you load a source file, it is automatically compiled (producing
.fasl
files (fast-load)) so that loading is much faster next time.可能最快的入门方法之一是使用 Lisp in a Box (或衍生产品如 LispBox)。 这些是您需要的一切的全套。
您还可以尝试 Lisp 资源工具包,这是一个可启动 CDROM Lisp 工具和文档,都已经为您设置好了。 只需将其放入 CDROM 驱动器并启动即可!
Probably one of the fastest ways to get started is to use Lisp in a Box (or a spinoff like LispBox). These are full sets of everything you need.
You could also try the Lisp Resource Kit, which is a bootable CDROM with Lisp tools and documentation, all already set up for you. Just put it into your CDROM drive and boot!
所有这些答案都很好,但是随着 Quicklisp 的流行,它们已经变得有点过时了。 非常宽松地说,quicklisp 是 asdf 的 make 的包管理器。 在系统上安装 Quicklisp 后,您可以使用
(ql:quickload "name of lisp library")
将该库加载到您的 Lisp 环境中,包括下载它及其任何依赖项(如果需要)。 例如,要下载、安装和加载 Hunchentoot 及其所有依赖项,请使用(ql:quickload "hunchentoot")
。 在以后的 lisp 会话中,再次调用(ql:quickload "hunchentoot")
将简单地加载已下载并安装的版本,使ql:quickload
成为加载任何库的简单方法本地或远程可用。 要安装 Quicklisp,我建议您访问 quicklisp.org。更详细的解释
Lisp 在库方面的工作方式与其他语言略有不同。 首先要知道的是,该语言本身几乎不提供库功能 - 它具有
load
(它会遍历并运行文件中的每一行,就像您在 REPL 中键入它们一样)和 < code>compile-file(它创建一个“快速加载”文件,这是文件的预编译版本,加载
并且可以执行得更快)。 仅使用核心语言提供的内容,为了加载库,您必须转到每个文件并加载
它(或(load (compile-file "filename"))< /code> 它,以获得更好的加载速度/性能)。 这变得很乏味,因此创建了各种库来管理库的加载,而目前
asdf
是王道(以至于许多 lisp 实现实际上都捆绑了它)。 在 asdf 术语中,库被称为“系统”,.asdf 文件描述了加载它们所涉及的所有元数据 - 它们依赖的系统以及加载文件的顺序,大多数情况下,但它们仍然可能变得相当复杂。 Quicklisp 位于 asdf 之上。 基本上,当 asdf 发现它无法找到某个系统时,Quicklisp 就会介入并检查该系统是否可以从 Quicklisp 的在线存储库之一获取,如果可以,则下载该系统并让 asdf 继续运行。ql:quickload
基本上只是 asdf 机制的包装器,用于加载系统,使 Quicklisp 能够根据需要提供帮助。All of these answers are good, however they've become a little outdated with the new popularity of Quicklisp. Very loosely speaking, quicklisp is the package manager to asdf's make. Once Quicklisp is installed on a system, you can use
(ql:quickload "name of lisp library")
to load that library into your lisp environment, including downloading it and any of its dependencies if required. For example, to download, install, and load Hunchentoot and all of its dependencies, use(ql:quickload "hunchentoot")
. In later lisp sessions, calling(ql:quickload "hunchentoot")
again will simply load the version already downloaded and installed, makingql:quickload
a simple way to load any library available locally or remotely. To install Quicklisp, I refer you to quicklisp.org.More detailed explanation
Lisp works a little differently from other languages when it comes to libraries. The first thing to know is that the language itself provides almost no library functionality- it has
load
(which goes through and runs each line in a file as if you'd typed them at the REPL) andcompile-file
(which creates a "fast load" file, a precompiled version of the file whichload
s and can perform much faster). Using just what the core language provides, in order to load a library you have to go to each of its files andload
it (or(load (compile-file "filename"))
it, for better load speed/performance). This got tedious, so a variety of libraries were created for managing the loading of libraries, and at the momentasdf
is king (so much so that many lisp implementations actually bundle it). In asdf terminology, libraries are called "systems" and .asdf files describe all of the metadata involved in loading them- the systems they depend on and what order to load files in, mostly, but they still can get quite complex. Quicklisp, then, sits on top of asdf. Basically, when asdf discovers that it cannot locate a system, Quicklisp steps in and checks to see if that system is available from one of Quicklisp's online repositories, and if so downloads it and has asdf continue on its way.ql:quickload
is basically just a wrapper around the asdf machinery for loading a system that enables quicklisp to help out as needed.