
Puppy Scheme
A Scheme compiler targeting WebAssembly.

A Scheme compiler targeting WebAssembly.
Compile a Scheme file to WebAssembly:
$ puppyc hello.scm -o hello.wasm
$ wasmtime -W gc hello.wasmUse a WIT file to define custom component exports:
$ puppyc app.scm --wit app.wit -o app.wasmThe compiler itself is a WASM module. puppyc is a thin wrapper around puppyc.wasm, which can be run directly by any WASI-compatible runtime:
$ wasmtime -W gc puppyc.wasm -- hello.scm -o hello.wasmPuppy Scheme components use closures for state. The define-component macro expands to a factory that creates fresh bindings per instance.
(define-component counter
(state (count 0))
(render
(html (div (@ (class "counter"))
(button (@ (on "click" "decrement"))
"-")
(span (@ (class "count"))
,(number->string count))
(button (@ (on "click" "increment"))
"+"))))
(dispatch event
(cond ((equal? event "decrement")
(if (> count 0)
(set! count (- count 1))))
((equal? event "increment")
(set! count (+ count 1))))))