ch:lexical-effect-handlers: ch:lexical-effect-handlers
Problem, result, and invariants. Build a finite trace model that separates operation names from lexical handler identities, then add the direct exchanger, one-shot resumption, and zero-Lexa clue calculations. The required result is the eight-line report in subsubappendix E.3.9. Maintain two invariants: identity lookup never changes the requested identity, and successful resume changes a fresh cell to consumed before returning.
Frames and the first obstruction. Give every handler frame four fields: identity, effect name, clause result, and exchanger address. Use the stack
Direct address and one-shot cell. The finite direct model resolves exchanger address
Hopper calculation. Represent a clue as a label index plus effect name or as a captured-effect clue. A label hopper replaces a specified input index with its caller index and retains the effect name. Check
Mainline boundary. Classify instructions only as move, call, return, or search. Require a mainline list of moves, a call, and a return to contain no search. Require a raise path to contain search. This checks list membership, not elapsed time or the native compiler’s data-section layout.
Failing versions and acceptance. First replace identity comparison with effect-name comparison. The two identity oracles must fail. Restore the source, then return a fresh cell from successful resume; the invalidation oracle must fail. Restore the accepted digest after each mutation. Run all four commands in subsubappendix E.3.9; require eight named PASS lines, the final acceptance line, and audit output [].
Mathematical boundary. The model checks eight finite calculations and two mutation failures. It proves no abstract-machine invariant, simulation, semantic preservation, source type safety, whole-compiler correctness, or cost theorem.