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.wasmTarget the browser or WASI:
$ puppyc app.scm --target web
$ puppyc app.scm --target wasiThe 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.wasmCompile Scheme to WebAssembly and build live components for the browser. This counter is server-rendered and hydrated on the client.
(define count 0)
(define (counter-view)
(html (div (@ (class "counter"))
(button (@ (on "click" "on_decrement")) "-")
(span (@ (class "count")) ,(number->string count))
(button (@ (on "click" "on_increment")) "+"))))
(define (handle-event handler)
(cond ((equal? handler "on_decrement")
(if (> count 0)
(set! count (- count 1))))
((equal? handler "on_increment")
(set! count (+ count 1)))))