An Unlambda interpreter in Rust
Relambda is a bytecode-compiling Unlambda interpreter in Rust.
$ relambda
>> `r`.!`.d`.l`.r`.o`.w`. `.,`.o`.l`.l`.e`.Hi
Hello, world!
You can find more sample programs at the comprehensive Unlambda archive network, and a tutorial and language spec on the Unlambda homepage.
Make sure you have cargo installed.
git clone https://github.com/MattX/relambda.git
cd relambda
cargo run
Relambda supports Unlambda 2.0. It supports arbitrary Unicode characters after .
, where the standard supports
ASCII. This means that you cannot print out raw bytes in the 127-255 range. Code is case insensitive, except for .
characters. Comments are supported.
Unlambda is compiled to a 6-instruction bytecode. Due to its very dynamic nature, most of the work is dynamically
dispatched by the Invoke
opcode.
Some integ tests are included. I've tested most of the programs in the CUAN
(ftp://ftp.madore.org/pub/madore/unlambda/CUAN/
). The test-runner
script will run
the suite of tests at ftp://ftp.madore.org/pub/madore/unlambda/tests/unlambda-tests
(which you need to download if you want to run them—I am not including them here as this file has no copyright
information.)
Very informal testing suggests that this interpreter is quite a bit faster than the C-refcount interpreter included in the official CUAN distribution. It's 2/3 as much code, but Rust is a higher-level language than C, and uses dependencies to manage argument parsing and output level control.