ref: 3c817d2e586dd916e39d54b2722c2e41a17c898d
dir: /README.md/
# femtolisp A compact interpreter for a minimal lisp/scheme dialect. 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. Tested on: 9front/arm64, OpenBSD/386, NetBSD/sparc64, Alpine/amd64, Android/arm64. Also runs on: MacOS 4.x-9.x, DOS. Some of the changes from the original include: * aggressive clean up, removal, renaming and refactoring * docstrings - `(define (f ...) "Docs here" ...)` and `(help ...)` * proper `(void)` and `void?` * better error reporting - disassembly at the current instruction, location of syntax errors * seamless bignums * `[` and `]`, `{` and `}` are synonyms to `(` and `)` * `λ` as a shorthand for `lambda` * some of the previously available (but not merged) patches from the community and [Julia](https://github.com/JuliaLang/julia) are applied * `c***r` of empty list returns empty list * "boot" image is built into the executable * vm opcode definitions and tables are generated from a single file * fixed bootstrap (makes it work properly when opcodes change) * built-in symbols aren't constants and can be redefined Two ways to learn about more changes: * https://todo.sr.ht/~ft/femtolisp?search=status:closed * https://git.sr.ht/~ft/femtolisp/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 --multiversal --ninja --no-carbon # wait until everything builds, make sure it did not error out Now build femtolisp: cd femtolisp ln -s ../retro68-build/toolchain cross/macos-toolchain # 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/flisp.dsk` or `build/flisp.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: ln -s djgpp-toolchain-prefix cross/djgpp-toolchain meson setup build . -Dbuildtype=minsize --cross-file cross/djgpp.txt ninja -C build Result is `build/flisp.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