Skip to content

bindings #5: WASM-exports calling pattern #414

@hyperpolymath

Description

@hyperpolymath

Child issue of #411 (bindings umbrella). Item bindings #5 in docs/bindings-roadmap.adoc.

What

Provide a way to invoke individual exports.fn_name(args) from a WasmExports value, from AffineScript code.

stdlib/Deno.affine already exposes:

  • WasmExports type
  • wasmInstance(bytes) -> WasmExports
  • readFile

What's missing is the calling surface — given a WasmExports value, how do you actually call individual exports by name?

Why

  • Idaptik vm/wasm (740 LoC across 2 files) is blocked here today.
  • Every future WASM-host integration in the estate will need this surface.
  • Smallest scope / highest leverage Tier-1 item in the bindings roadmap.

Two approaches (pick one)

Option A — Generic dynamic call: one extern, ~10 lines:

extern fn wasm_call(exports: WasmExports, name: String, args: [Float]) -> Float

Pros: tiny surface, future-proof. Cons: stringly-typed, no compile-time check that the export exists.

Option B — Per-export typed externs: ~30 extern fn declarations matching the specific exports idaptik's vm/wasm Zig module ships.
Pros: typed, compile-time-checked. Cons: brittle to changes in the Zig module's export list.

The roadmap doc leans toward Option A as the generic surface, with Option B's typed shape achievable via per-consumer wrapper modules layered on top.

Where it lives

stdlib/Deno.affine extension, or a new stdlib/wasm.affine (decide as part of this issue).

Done when

Refs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions