// ref/hare/io/empty.ha:4-17. // // Hare uses `const _empty_vt: vtable = { ... }` + `const empty: *stream`. // ww can't const-init a vtable struct with fn-ptr fields (#118), so the // vtable is a module-level `let` and [[empty]] is a function that wires // the fn-ptr slots on every call and returns the stream pointer. // Single-assignment on the same words: idempotent under re-entry. // Lives in empty.ww (not io.ww) so io.ww stays standalone without // referencing the cross-file vtable/reader/writer types. package io; fn _empty_read(s: stream, buf: []u8) (size | eof | error) = { let e: eof; return e; }; fn _empty_write(s: stream, buf: []u8) (size | error) = { return buf.len: size; }; let _empty_vt: vtable; // empty — a stream that discards all writes (returning their size) and // returns EOF on every read. Mirrors ref/hare/io/empty.ha:13. // #118: const vtable init with fn-ptr fields is unwired (emit_struct_data // needs a two-pass reloc extension, node_fnptr_sym reusable). Using a // mutable let + per-call wiring until #118 lands. export fn empty() stream = { _empty_vt.reader = (&_empty_read): *reader; _empty_vt.writer = (&_empty_write): *writer; return &_empty_vt; };