Skip to main content

reed source to readable wat

Reed

Reed is a small typed language for writing one WebAssembly module at a time. It keeps the Wasm shape visible, gives you source-level names and checks, and emits WAT that is still pleasant to inspect by hand.

It is useful when raw WAT is too repetitive, but a general-purpose language is too far away from the machine you want to control.

Read the guideOpen the playgroundView the spec

Current shape

version
0.1.0, with no compatibility promise yet
catalog
reedc-core-gc-eh-simd-threads-1
target
core Wasm, references, GC, EH, SIMD, threads, memory64
output
commented WAT, meant to be read

The project is young. Syntax can change between commits, and correctness still depends on the cases the conformance suite actually exercises. If you plan to rely on emitted modules, read the limitations first.

A complete module

This source declares a mutable global, increments it, and exports the function under an explicit WebAssembly ABI name.

counter.reed

global Counter: mut i32 = 0;

func increment() -> i32 {
  Counter = Counter + 1;
  return Counter;
}

export func increment as "increment";

counter.wat

;; reedc catalog: reedc-core-gc-eh-simd-threads-1
(module
  ;; func increment(...)
  (func $increment
    (result i32)
    ;; Counter = Counter + 1;
    (global.set $Counter
      (i32.add (global.get $Counter) (i32.const 1)))
    ;; return Counter;
    (return (global.get $Counter)))
  ;; global Counter: ... = ...;
  (global $Counter (mut i32) (i32.const 0))
  ;; export func increment as "increment";
  (export "increment" (func $increment)))

Language notes

Useful pages