通用Lisp软件包和模块管理

编程入门 行业动态 更新时间:2024-10-26 02:25:45
本文介绍了通用Lisp软件包和模块管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我当前正在尝试了解Common Lisp如何管理其程序包和模块。

I am currently trying to understand how Common Lisp manages its packages and modules.

考虑以下代码:

(in-package :cl-user) (ql:quickload :cl-who) (ql:quickload :hunchentoot) (ql:quickload :parenscript) (defpackage :retro-games (:use :cl :cl-who :hunchentoot :parenscript)) (in-package :retro-games) (defclass game () ((name :initarg :name) (votes :initform 0)))

当我创建一个Slime缓冲区,然后在设置为Slime模式的另一个缓冲区中运行此代码时,我看到了一些打印内容在 * slime-repl sbcl * 的第一个缓冲区中:

When I create a Slime buffer and then run this code in another buffer that is set to Slime mode, I see some prints in the first buffer that is *slime-repl sbcl*:

Load 1 ASDF系统: cl-who;加载 cl-who

Load 1 ASDF system: cl-who ; Loading "cl-who"

要加载 parenscript:加载1个ASDF系统: parenscript;加载 parenscript ..

To load "parenscript": Load 1 ASDF system: parenscript ; Loading "parenscript" ..

加载 hunchentoot:加载1个ASDF系统: hunchentoot;正在加载 hunchentoot ..............

To load "hunchentoot": Load 1 ASDF system: hunchentoot ; Loading "hunchentoot" ..............

也就是说,似乎有些在两个缓冲区之间进行对话。但是,如果我尝试运行(make-instance game( Chess)),则会收到错误,因为 CL-USER 包不知道游戏类。

That is, there seems to be some "talking" going on between the two buffers. However, if I try to run (make-instance game("Chess")), I get an error because the CL-USER package does not know about the game class.

另一方面,如果我运行(在包中:复古游戏)在 slime repl sbcl 缓冲区中,我能够运行(制作实例游戏(国际象棋))。

On the other hand if I run (in-package :retro-games) in the slime repl sbcl buffer, I am able to run (make-instance game("Chess")).

问题是Common Lisp如何通过软件包组织其工作?在相关说明中,缓冲区为 slime repl sbcl 和缓冲区为 slime-mode 有什么区别? ?

The question is how does Common Lisp organize its work with packages? On related note, what is the difference between a buffer being a slime repl sbcl and a buffer being in slime-mode?

这些软件包是否与Python的虚拟环境完全相似?也就是说, CL-WHO , HUNCHENTOOT 和 PARENSCRIPT

Are the packages at all similar to Python's virtual environments? That is, where are the CL-WHO, HUNCHENTOOT and PARENSCRIPT being installed in my case? Do I have any choice over this?

推荐答案

首先,尝试(make-instance'game:name 国际象棋)。 注意,Common Lisp在Paarenthesis之间使用前缀表示法。因此,如果要调用 foo( bar)之类的函数,则为(foo bar)。 如果需要,可以创建一个函数,例如:

First, try (make-instance 'game :name "Chess"). Note that Common Lisp uses prefixed notation between paarenthesis. So, if want to call a function like foo("bar"), it would be (foo "bar"). If you want, you can create a function like:

(defun new-game(game-name) (make-instance'game:name游戏名称))

如果您使用的是Quicklisp,则可将软件包安装在您安装的位置已安装quicklisp。如果安装在您的主文件夹中,则软件包应位于 / home / user / quicklisp / dists / quicklisp / software / 。

If you are using Quicklisp, the packages me be installed at where you've installed quicklisp. If it is installed at your home folder, the packages should be at /home/user/quicklisp/dists/quicklisp/software/.

更多推荐

通用Lisp软件包和模块管理

本文发布于:2023-11-24 08:47:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624529.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:软件包   模块   Lisp

发布评论

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

>www.elefans.com

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