branches: main
Clone
clone: git://shithub.us/sigrid/sl gits://shithub.us/sigrid/sl
push: hjgit://shithub.us/sigrid/sl
patches to: sigrid on #cat-v
Last commit
a70379d7
– Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
authored
on 2025/03/30 23:01
for-each: operate on runes of a string rather than bytes
About
# StreetLISP
< cinap_lenrek> maybe thats all you need
< cinap_lenrek> a street lisp
< cinap_lenrek> sl(1)
[](https://builds.sr.ht/~ft/sl/commits/main/.build.yml?)
[Coverage report](https://ftrv.se/_/sl/index.html)
A compact interpreter for a minimal lisp/scheme dialect. A street lisp.
This is a reanimation of
https://github.com/lambdaconservatory/femtolisp with bigger plans.
Supported OS: [9front](http://9front.org), Unix-like operating systems (OpenBSD, NetBSD, Linux, etc).
Supported CPUs: any decent 32 or 64-bit, little or big endian.
Regularly tested on: 9front, OpenBSD, NetBSD, Alpine, Android.
Also runs on: MacOS 4.x-9.x, Mac OS X, Haiku, DOS.
Some of the changes from the original include:
* aggressive clean up, removal, renaming and refactoring
* bignums
* previously available (but not merged) patches from the community and [Julia](https://github.com/JuliaLang/julia) are applied
* `[` and `]`, `{` and `}` are synonyms to `(` and `)`
* `«` and `»` for verbatim strings
* `define` → `def`, `define-macro` → `defmacro`
* `λ` as a shorthand for `lambda`
* `T` instead of `#t`/`#T` and `NIL` instead of `#f`
* `c***r` of empty list returns empty list
* docstrings - `(def (f ...) "Docs here" ...)` and `(help ...)`
* automatic gensyms for macros (`blah#`) at read time
* proper `(void)` and `void?`
* better error reporting - disassembly at the current instruction, location of syntax errors
* "boot" image is built into the executable
* vm opcode definitions and tables are generated from a single file
Two ways to learn about more changes:
* https://todo.sr.ht/~ft/sl?search=status:closed
* https://git.sr.ht/~ft/sl/log
## Building
### POSIX
meson setup build -Dbuildtype=release
ninja -C build test
### Plan 9
mk all test
### MacOS 4.x-9.x (m68k or PowerPC)
Clone and build [Retro68](https://git.sr.ht/~ft/retro68). This fork grabs the
necessary patches for more things to work as expected:
git clone https://git.sr.ht/~ft/retro68
mkdir retro68-build
cd retro68-build
../retro68/build-toolchain.bash --ninja
# wait until everything builds, make sure it did not error out
Now build `sl`:
cd sl
export PATH="$PATH:$(pwd)/../retro68-build/toolchain/bin"
# for PowerPC:
meson setup build . -Dbuildtype=minsize --cross-file cross/powerpc-apple.txt
# for m68k:
meson setup build . -Dbuildtype=minsize --cross-file cross/m68k-apple.txt
ninja -C build
Either `build/sl.dsk` or `build/sl.bin` is the file to get on your Mac.
NOTE: this isn't a full-fledged port and is going to stay low priority unless somebody
wants to spend time polishing it.
### DOS
Build DJGPP cross-compiler, then:
export PATH=$PATH:path-to-djgpp-toolchain/bin
meson setup build . -Dbuildtype=minsize --cross-file cross/djgpp.txt
ninja -C build
Result is `build/sl.exe`.
## Characteristics
* lexical scope, lisp-1
* unrestricted macros
* case-sensitive
* simple compacting copying garbage collector
* Scheme-style varargs (dotted formal argument lists)
* "human-readable" bytecode with self-hosted compiler
* circular structure can be printed and read
* `#.` read macro for eval-when-read and readably printing builtins
* read macros for backquote
* symbol character-escaping printer
* exceptions
* gensyms (can be usefully read back in, too)
* `#| multiline comments |#`, `#;(block comment...`, lots of other lexical syntax
* generic compare function, cyclic equal
* cvalues system providing C data types ~~and a C FFI~~
* constructor notation for nicely printing arbitrary values