comp.ts is back under its 64k cap: the compiler says the same in fewer tokens, with the same output - #1285
Merged
Conversation
…r tokens, with the same output #1269 took comp.ts to 64,250 ttok and later merges to 64,251, past the permanent 64,000 cap. These cuts are pure rewrites of the TypeScript compiler: one-line OPERATIONS entries, ternaries for chains of early returns, the once-used facts_fam, facts_lend and mat_nats inlined at their call sites, and locals used once inlined. The emitted C, JS and .mjs of every .bend under tests/, bench/ and demos/ (4,857 outputs, error texts included) are byte-identical to main's. comp.ts is at 63,883 ttok. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
bend2/comp.tshas been over its permanent 64,000 ttok cap since #1269, which took it from 63,536 to 64,250. Four later merges added more and #1230 took 110 back, leaving main at 64,251, sogates/repo.tsfails on main. This went unnoticed until #1283 because the gate read a failedttokrun as 0.This PR brings
comp.tsto 63,883 ttok (−368). That leaves 117 tokens for the PRs waiting on the cap.Change (
bend2/comp.tsonly)These are pure rewrites of the TypeScript compiler, the same kind as #1230. Nothing in the C or JS runtime templates changes.
OPERATIONS: entries whose C and JS texts fit on one line are written on one line.val_to,emit_args,emit_match,js_match,js_call,term_force,tpl_nat,lay_of,anf'sLamcase andemit_unfold'sbind.facts_fam,facts_lendandmat_natsmove into their one call site each.load,last,ids,tagand theval_holdresults are inlined.#defineid loop becomes aflatMap;graph_closeadds while it scans instead of filtering first; thebind_poploop becomes a single??=.ERRS: the placeholders are filled withreplaceAllbefore the split.show_mainandval_arm: dot access, andNumber(bool)instead of? 1 : 0, aslay_packalready does.Not taken: rewrites that bypass an abstraction (pushing to
seg.linesdirectly instead offile_push), parameter-default tricks,Set.addused for its truthiness, and turningswitchdispatches into long ternary chains. The last would save about 44 more tokens if they are ever needed.Checks
On 0a1a769, against main ee8a156:
.bendundertests/,bench/anddemos/(1,619 files) to.c,.jsand.mjswith main and with this branch. All 4,857 results are byte-identical: the 2,528 emitted files and the error text of the 2,329 that fail to build.comp.ts.gates/repo.ts: PASS 49 / 49. Main fails it, oncomp.ts.gates/test.ts: PASS 1536 / 1536.gates/ping.ts: PASS 46 / 46.gates/perf.ts, run alone: 124 / 124 here, 123 / 124 on main back to back.#1281 also brings
comp.tsunder the cap, by removing mechanisms. It rewrites much of the same code, so whichever lands second will need a rebase.🤖 Generated with Claude Code