You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Array structural split/join allocates and copies (blk_half/blk_node); the paper says both halves come in place and joining is free #804
Compared the runtime paper's array cost model with the emitter and runtime routines in the current tree (source reading only; no timing was measured).
What happened
The paper (bend2/docs/BendRT/main.typ, § Arrays): "A match on the tree takes both halves in place, and joining two adjacent halves back is free."
The emitter (bend2/comp.ts at 0b7e2b1): an ArrayANode{l, r} constructor emits blk_node(e, l, r) (line 2228), and a match on ANode emits two blk_half(e, sw, hi) calls (line 2647). Those routines allocate and copy: blk_node (line 4068) allocates the merged block, copies both halves word by word, then frees both inputs; blk_half (line 4093) allocates and copies each half, then frees the source on the high call. The compiler's own comment (lines 4007-4016) states it: "A match on ANode is blk_half twice: each half allocated in its class and copied... ANode{l, r} is blk_node: the merged class, l and r copied and freed shallow... A match to the leaves copies O(n log n) words where a view copied none; get, set, swap, size and new open no half."
So for materialized structural split/join (indexed get/set opens no half), the paper's cost model does not match the implementation. Either the paper should say allocate-and-copy, or the views should be implemented.
The paper was stale: arrays copied on split/join since views were dropped (a view changed class on every split and leaked a slot per iteration). The BendRT paper now says a match copies each half into its own block and a node copies both back, O(n log n) words on a walk to the leaves; get, set and swap open no half. The PDF is rebuilt in the repo.
Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.
Activity
VictorTaelin commentedon Sep 18, 2026
The paper was stale: arrays copied on split/join since views were dropped (a view changed class on every split and leaked a slot per iteration). The BendRT paper now says a match copies each half into its own block and a node copies both back, O(n log n) words on a walk to the leaves; get, set and swap open no half. The PDF is rebuilt in the repo.
Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.
The BendRT paper says an array match copies its halves and a node cop…
The BendRT paper says an array match copies its halves and a node cop…