84 releases (6 breaking)

new 0.7.4 Dec 4, 2024
0.7.2 Nov 27, 2024
0.5.1 Jul 15, 2024
0.3.23 Mar 31, 2024
0.2.0 Oct 17, 2023

#612 in Memory management

Download history 756/week @ 2024-08-17 1142/week @ 2024-08-24 1103/week @ 2024-08-31 608/week @ 2024-09-07 1032/week @ 2024-09-14 595/week @ 2024-09-21 1800/week @ 2024-09-28 1059/week @ 2024-10-05 270/week @ 2024-10-12 616/week @ 2024-10-19 673/week @ 2024-10-26 251/week @ 2024-11-02 318/week @ 2024-11-09 521/week @ 2024-11-16 712/week @ 2024-11-23 800/week @ 2024-11-30

2,353 downloads per month
Used in 23 crates (14 directly)

Custom license

51KB
1.5K SLoC

Stak Scheme

GitHub Action Crate Codecov License

The no-std and no-alloc R7RS Scheme implementation in Rust

The documentation is here.

License

MIT


lib.rs:

A virtual machine and its runtime values.

Examples

use stak_device::FixedBufferDevice;
use stak_file::VoidFileSystem;
use stak_macro::compile_r7rs;
use stak_process_context::VoidProcessContext;
use stak_r7rs::SmallPrimitiveSet;
use stak_time::VoidClock;
use stak_vm::Vm;

const HEAP_SIZE: usize = 1 << 16;
const BUFFER_SIZE: usize = 1 << 10;

let mut heap = [Default::default(); HEAP_SIZE];
let device = FixedBufferDevice::<BUFFER_SIZE, 0>::new(&[]);
let mut vm = Vm::new(
    &mut heap,
    SmallPrimitiveSet::new(
        device,
        VoidFileSystem::new(),
        VoidProcessContext::new(),
        VoidClock::new(),
    ),
).unwrap();

const PROGRAM: &[u8] = compile_r7rs!(r#"
    (import (scheme write))

    (display "Hello, world!")
"#);

vm.initialize(PROGRAM.iter().copied()).unwrap();
vm.run().unwrap();

assert_eq!(vm.primitive_set().device().output(), b"Hello, world!");

Dependencies