在引导扇区中自举 Lisp
Bootstrapping Lisp in a Boot Sector

原始链接: https://github.com/jart/sectorlisp

SectorLISP项目旨在将LISP语言简化到其最本质的形式,如同寻找软件的“麦克斯韦方程组”一样。它提供了一个512字节的i8086 LISP实现,能够直接从BIOS引导John McCarthy的元循环求值器。据称这是最小的“真正”LISP实现。 该项目包括: 1. **`lisp.lisp`:** 一个纯LISP表达式,包含经过错误修复的元循环求值器以及仅有的基本函数。 2. **`lisp.c`:** 一个可移植的C语言参考实现,展示了在POSIX系统上使用类似readline的界面的原生引导过程。 3. **`sectorlisp.S`:** 一个512字节的i8086实现,用于在PC上从BIOS启动。 C语言实现可以使用`make`进行编译。`sectorlisp.bin`文件可以从软盘启动,或者使用Das Blinkenlights或QEMU进行模拟。提供的LISP代码示例可以在REPL中测试。一个展示元循环求值器引导和运行简单程序的演示视频可在YouTube上观看。

Hacker News 最新 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 在引导扇区中引导 Lisp (github.com/jart) gone35 5小时前 32 分 | 隐藏 | 过去 | 收藏 | 1 评论 dang 28分钟前 [–] 相关:Sectorlisp - https://news.ycombinator.com/item?id=34372765 - 2023年1月 (8条评论) 回复 考虑申请 YC 2025 年夏季批次!申请截止日期为 5 月 13 日 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系我们 搜索:
相关文章

原文

sectorlisp is a 512-byte implementation of LISP that's able to bootstrap John McCarthy's meta-circular evaluator on bare metal.

Yo dawg, I heard you like LISP so I put a LISP in your LISP so you can eval while you eval

LISP has been described as the Maxwell's equations of software. Yet there's been very little focus to date on reducing these equations to their simplest possible form. Even the original LISP paper from the 1960's defines LISP with nonessential elements, e.g. LABEL.

This project aims to solve that by doing three things:

  1. We provide a LISP implementation that's written in LISP, as a single pure expression, using only the essential functions of the language. See lisp.lisp. It's the same meta-circular evaluator in John McCarthy's paper from the 1960's, except with its bugs fixed, dependencies included, and syntactic sugar removed.

  2. We provide a readable portable C reference implementation to show how the meta-circular evaluator can be natively bootstrapped on POSIX conforming platforms, with a pleasant readline-like interface. See lisp.c.

  3. We provide a 512-byte i8086 implementation of LISP that boots from BIOS on personal computers. See sectorlisp.S. To the best of our knowledge, this is the tiniest true LISP implementation to date.

Binary Footprint Comparison

See lisp.lisp for code examples that you can copy and paste into your LISP REPL.

You can run the C implementation as follows:

After running make you should see a sectorlisp.bin file, which is a master boot record you can put on a flopy disk and boot from BIOS. If you would prefer to run it in an emulator, we recommend using Das Blinkenlights.

curl --compressed https://justine.lol/blinkenlights/blinkenlights-latest.com >blinkenlights.com
chmod +x blinkenlights.com
./blinkenlights.com -rt sectorlisp.bin

Alternatively you may use QEMU as follows:

qemu-system-i386 -nographic -fda sectorlisp.bin

Further information may be found on our wiki.

booting sectorlisp in emulator

The video above demonstrates how to boot sectorlisp in the blinkenlights emulator, to bootstrap the meta-circular evaluator, which evaluates a program for finding the first element in a tree.

You can watch the full demo on YouTube.

联系我们 contact @ memedata.com