
Scheme-rs: Embedded Scheme for the Rust Ecosystem¶
Scheme-rs is an implementation of the R6RS specification of the Scheme programming language that is designed to be embedded within sync and async Rust.
;; Example of a program that defines a variable via a datum received over a
;; socket.
;;
;; Requires the `async` and `tokio` features enabled.
(import (rnrs) (async))
(define-syntax expand-from-socket
(lambda (x)
(syntax-case x ()
[(ctxt)
(let ([listener (bind-tcp "0.0.0.0:8080")])
(let-values ([(port addr) (accept listener)])
(let* ([port (transcoded-port port (native-transcoder))]
[recvd-syntax (datum->syntax #'ctxt (get-datum port))])
(write 'thanks! port)
(close-port port)
recvd-syntax)))])))
(define var-from-network (expand-from-socket))
Features:¶
- Modern: scheme-rs is a modern scheme implementation of the R6RS standard and includes advanced features such as delimited continuations.
- Fast: scheme-rs uses JIT compilation to provide performance on par with other modern scheme implementations.
- Easy to use: scheme-rs makes it trivial to define Rust functions and data structures that are accessible from scheme code and vice-versa.
- Safe: scheme-rs provides a completely safe API that is impossible to misuse.
- Supports both async and sync Rust: by enabling the
asyncfeature flag it becomes possible (and easy) to define async scheme functions in Rust.
Getting started:¶
For embedding scheme-rs in your Rust project, take a look at the API documentation.
For installing scheme-rs as a standalone executable, cargo can be used:
To enable async features, install with the async and tokio features:
Supported platforms:¶
scheme-rs uses cranelift for JIT compilation and is therefore limited to platforms supported by cranelift. At the current moment that includes x86-64, aarch64 (ARM64), s390x (IBM Z), and riscv64 architectures.
scheme-rs has been tested on the following platforms:
- Linux (fully supported, primary platform)
- MacOs (occasionally tested)
- Windows (previously tested, not tested in a while)
Documentation¶
Contributing¶
If you have any questions or comments about the project, feel free to join the scheme-rs discord server.