Skip to content
This repository was archived by the owner on Aug 12, 2026. It is now read-only.

Commit 0d0c736

Browse files
committed
Host imports, scalar slice: a component can call Clojure through cljwit.host
(host/instantiate art {:imports {"local:imp/host@0.1.0#twice" (fn [v] (* 2 v))}}) ((i "run") 20) ;=> 41 An upcall stub per import, built from the reflected import type the same way export marshallers are, and bound to a Clojure reify. Missing imports stay wasmtime's to report -- its message names the interface and the function, which 0017's first draft denied and one command disproved. What the host checks is the other direction: a key nobody needs is a typo, and silently ignoring it is the nil-on-typo failure 0014 rejected. An exception in an import surfaces to the caller with its own message and marks the instance dead. That is not politeness -- measured, such an error poisons the whole store, so without the flag every later call reports "cannot enter component instance" with the cause gone. Fault injection: removing the marking turns the suite red, so the assertion is not decorative. Scalars only, deliberately. Anything wasmtime would have to free -- a string, a list, a boxed option -- needs lower-fn to allocate with malloc rather than from an Arena (0017 C), and handing wasmtime an Arena pointer to free() is heap corruption rather than a wrong answer. Refused at instantiate with the kind named, the same shape the export direction uses. 97 assertions. Claude-Session: https://claude.ai/code/session_01XF5Hfq4Ca2N2XYEzWQQuHt
1 parent 8038572 commit 0d0c736

3 files changed

Lines changed: 261 additions & 83 deletions

File tree

‎dev/resources/imp.wit‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// A component that *imports* a function, so the guest can call back into the
2-
// host. `0014` names host imports as its most-likely-to-fire falsifier: WASI
3-
// needs them, and they break both its in-call flag and its reused argument
4-
// buffer, because a call can then nest.
51
package local:imp@0.1.0;
62
interface host { twice: func(v: u32) -> u32; }
73
world w {

0 commit comments

Comments
 (0)