让Eclipse也能编译CommonLisp!

结月lalalll

阅读本文章前,请确保您具备:
1.基本的阅读及理解能力
2.基本的搜索引擎使用意识
3.已经配置好的Eclipse环境
4.已经搭建在本地的SBCL环境

注意! 本人环境为Windows 10 Eclipse 2021-09 (4.21.0) SBCL 2.3.2 不保证其他版本操作无异


最开始的时候在选择CommonLisp还是Scheme上犹豫了挺长时间,最终还是选择了CommonLisp.
奈何VimEmacs的确劝退啊!
硬着头皮学习了一段时间后,终于发现了这款可以在Eclipse上编译CommonLisp的插件.

实际上这篇文章本该在去年就写出来的XD

为Eclipse安装Dandelion插件

https://github.com/Ragnaroek/dandelion

方式一:Marketplace install

打开Marketplace,搜索Dandelion,无脑安装.

方式二:Update-Site installation

添加更新站点: https://ragnaroek.github.io/dandelion/ ,选择你要拉取的版本(一定要把系统和Lisp实现选择准!),无脑安装.

搭建自己的SBCL环境

参考自:https://github.com/Ragnaroek/dandelion/wiki

激动的进入eclipse,发现插件所使用的SBCL(2.0.1)是内置且过时的,你很不爽,想要使用自己的SBCL(2.3.2),于是你…

拉取Dandelion

在一个安全的文件夹使用 git clone https://github.com/Ragnaroek/dandelion.git 来拉取一份代码

我因为官方源超时了,换用了镜像源╮(╯▽╰)╭

安装Quicklisp

为本地的SBCL安装Quicklisp,访问 https://www.quicklisp.org/beta/ 获得quicklisp.lisp

在文件目录下打开CMD

1.启动SBCL并加载quicklisp.lisp:
sbcl --load quicklisp.lisp

2.安装Quicklisp:
(quicklisp-quickstart:install)

3.让SBCL启动时自动加载QuickLisp:
(ql:add-to-init-file)

构建核心文件

进入dandelion\Environment,找到一份build.lisp文件,打开它
编辑(defparameter *binary-path* "/Users/mb/tmp/env")字段
/Users/mb/tmp/env改为你想要存放核心文件的地址,例如D:/a/a.core

一定要把路径的结尾落到.core文件自身,如果结尾是文件夹会报错!!!

路径是"斜线"而不是"反斜线".

接下来在文件目录下打开CMD

1.启动SBCL并加载build.lisp
sbcl --load ./build.lisp

2.在指定位置构建核心文件
(build)

如果一切正常,本操作会输出以下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
>sbcl --load ./build.lisp

This is SBCL 2.3.2, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
To load "dandelion-server":
Load 1 ASDF system:
dandelion-server
; Loading "dandelion-server"
.....

* (build)

[undoing binding stack and other enclosing state... done]
[performing final GC... done]
[saving current Lisp image into D:\b\a.core:
writing 5888 bytes from the static space at 22110000
writing 25427968 bytes from the dynamic space at 22210000
writing 6803784 bytes from the read-only space at 043a0000
done]

F:\GitBuild\dandelion\Environment>

你可以在你指定的文件夹找到.core文件

启动eval-server

在.core文件同目录下打开CMD
输入sbcl --core a.core 40123 NIL DEBUG
其中a.core为.core文件的名称,40123为eval-server的指定端口号

如果一切正常,本操作会输出以下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
>sbcl --core a.core 40123 NIL DEBUG

This is SBCL 2.3.2, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
<DEBUG> [00:08:39] dandelion-server server.lisp (start-eval-server) -
Eval-Server started at 04.04.2024 00:08:39
SERVER_UP
<DEBUG> [00:08:39] dandelion-server server.lisp (start-eval-server) -
Waiting for client connect...

有时候由于端口占用可能会导致服务器启动失败,换个端口号就好了

连接eval-server

在eclipse的设置中配置Lisp环境

在REPL中输入简单命令来连接我们的服务器,成功,同时终端日志开始刷新

至此,我们就构建好了自己的SBCL eval-server

开始快乐的学习之旅吧!

  • 本文标题:让Eclipse也能编译CommonLisp!
  • 本文作者:结月lalalll
  • 创建时间:2024-04-03 22:44:20
  • 本文链接:https://lalalll-lalalll.github.io/code/Lisp-on-Eclipse/
  • 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!