Repository navigation
A literal is one node per kind: Lit{k, v} steps through lit_step, and U32 and F32 literals are kinds - #1003
Closed
nicolas-abril wants to merge 1 commit into
Closed
A literal is one node per kind: Lit{k, v} steps through lit_step, and U32 and F32 literals are kinds#1003nicolas-abril wants to merge 1 commit into
nicolas-abril wants to merge 1 commit into
Conversation
… String, U32, F32), and lit_step steps it one constructor out, so U32 and F32 literals are one node too
Checking, comparing, printing, patterns and the compiler all read a
literal through lit_step, so a new kind is a Lit variant, its case and a
parse rule. A char literal and a string's step hold the character as
Chr{U32 literal}. Ctr and u32_to_term return the Ctr variant. The u32/f32
tests are from bendlang#936.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
MattCozendey
added a commit
to MattCozendey/bend
that referenced
this pull request
Sep 23, 2026
The Nat, U32, F32 and String sugar already prints each step, so the per-kind ternary goes and a new kind prints with no printer code; the idea is from bendlang#1003. 303 representative tests, all show and check tests (240) and the demos print as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ma2csvkz5EeH5N2MiF8JPL
This was referenced Sep 23, 2026
MattCozendey
added a commit
to MattCozendey/bend
that referenced
this pull request
Sep 24, 2026
The Nat, U32, F32 and String sugar already prints each step, so the per-kind ternary goes and a new kind prints with no printer code; the idea is from bendlang#1003. 303 representative tests, all show and check tests (240) and the demos print as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ma2csvkz5EeH5N2MiF8JPL
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.
Draft: this needs a decision on
bend2/bend.ts's ttok cap before it can land (see Size below). It is an alternative to #936, which adds U32 and F32 literals by taggingLitwith an optionalk.What this changes
Since #907 and #924, a string or nat literal is one
Litnode that unfolds one constructor at a time where it is read. Its kind was implicit intypeof v, and each reader (the step, the full unfolding, check-lit, the printer,nat_from_term) spelled out Nat and String by hand. #936 extends that to U32 and F32 with ak !== undefinedbranch at each of those sites.Here every literal carries its kind, and the kind decides the payload's type:
lit_stepis the only code that knows a kind: onecaseper kind, returning the constructor it unfolds to. Everything else reads a literal through it:term_compare(a mixed Lit/Ctr pair steps the literal) and infer-err, as before;lit_full(patterns, and the compiler'sterm_force) is one worklist that steps any literal it finds in a step's fields;So a new kind is a
Litvariant, itscase, and its parse rule. Kinds nest: a string's step holds its character asChr{U32 literal}rather than a 33-word chain, and a char literal'c'parses to the same 2-node shape.Ctrandu32_to_termreturn theCtrvariant, solit_stepneeds no cast, and narrowing onktypesv, so the readers need none either.In
comp.tsonly the big-Nat case ofterm_forcechanges (s.k === "Nat").Measurements
Apple M4, min of 5, seconds / peak MB:
--check-only--check-only--check-only-o main.c--check-only-o main.cThe extra ~12 MB against #936 on the literal-per-def files is check-lit building a U32's first step (its word) where #936 reads the head from the tag. String-heavy programs (2000 string defs, a 100-case string match) are unchanged from main on all three.
Tests
bend t.bend) over all 1429 tests undertests/prints the same as main.check/,compile/,parse/,printer/andproof/*_literal_*,parse/nat_plus_u32) are included and pass; the two compile tests print right on C and JS and emit the same code as main.Size
bend.ts42979 → 43217 ttok, over the 43000 cap ingates/repo.ts, sobun gates/repo.tsfails. #936 costs about the same and raises the cap to 43200. The choice is to raise the cap to ~43300 or to find that much elsewhere in the file.The u32/f32 tests are @MattCozendey's, from #936.
🤖 Generated with Claude Code