feat(#5525): file-local name handles for anonymous >> objects via >> foo#5528
Merged
Conversation
Extend the `>>` auto-name suffix to optionally carry a trailing NAME — a file-local handle. `[n] >> fibo` keeps the object anonymous (it still gets its deterministic cactus @name per §9.2) while `fibo` becomes a typeable alias usable anywhere in the same .eo file: self-recursion, mutual recursion, or a call from a sibling attribute — none of which expose the object on the enclosing surface, unlike plain `> name`. Parser front-end: `Suffix.auto()` reads an optional handle after `>>` (and `!`), surfaced via `Suffix.handle()`; `Emit.local()` records it as an `@local` marker on the object carrying the cactus `@name`, emitted by LnFormation, LnOnlyPhi and ChainEmission. A new first-pass `resolve-local-names.xsl` (wired into Canonical right after `resolve-self`, before `build-fqns`) collects the per-file `@local -> @name` table, rewrites every `@base` equal to a handle into the matching cactus name, drops the markers, and reports a duplicate handle as a compile-time error. Pure syntactic sugar; nothing changes below the parser front-end. Supersedes the reverted `%` (#5433). PARSER_SPEC.md gains R-3.10.12 and R-9.2.3; adds parse-pack tests for the rewrite and the duplicate-handle error plus Suffix unit tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TB27TwPXPJ3c7bKZbxerxj
|
Contributor
|
yegor256
marked this pull request as ready for review
July 15, 2026 18:03
|
@yegor256 Thanks for the contribution! You've earned +4 points for this: +16 as a basis; -4 for too many hits-of-code (197 >= 100); -8 for the lack of code review. Please, keep them coming. Your running score is +1808; don't forget to check your Zerocracy account too). |
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.



Closes #5525.
What
Extends the
>>auto-name suffix to optionally carry a trailingNAME— a file-local handle:>> fibokeeps the object anonymous — it still receives its deterministic cactus@name(§9.2) and never enters the visible namespace — butfibobecomes a typeable alias for that cactus name, usable anywhere in the same.eofile. Herefibois referenced twice recursively inside its own body and once fromapp's@, and all three rewrite to the same cactus@name. Unlike plain> fibo, the object is never put onapp's public surface. Pure syntactic sugar — no new semantics.This supersedes the reverted
%(#5433):%self-referenced only the nearest enclosing anonymous formation, whereas>> foogives a typeable handle to any anonymous object reachable from anywhere the cactus name is in scope (self-recursion, mutual recursion, sibling calls).How
Mirrors the marker + first-pass-XSL pattern of #5432 / #5522.
Suffix.auto()reads an optional handle after>>(and the!const), surfaced via the newSuffix.handle().Emit.local()records it as an@localmarker on the object that carries the cactus@name; it is emitted byLnFormation,LnOnlyPhiandChainEmission, so>> nameis accepted uniformly on bare formations, inline-phi formations and applications.!const stays allowed (>>! name);/sigstays forbidden (R-3.10.2).resolve-local-names.xsl, wired intoCanonicalright afterresolve-self.xsl, beforebuild-fqns.xsl/ scope resolution. It (1) collects the per-file@local → @nametable, (2) rewrites every@baseequal to a handle into the matching cactus@name, (3) drops the@localmarkers, and (4) reports a duplicate handle as aresolve-local-namescompile-time error (duplicate local name 'name'). A reference with no matching handle is left untouched for later scope resolution. Downstream passes see only ordinary references by the reserved cactus name — nothing changes below the parser front-end.PARSER_SPEC.mdgains R-3.10.12 (file-local handles) and R-9.2.3 (emission + rewrite), plus the>>base-form table entry.Tests
eo-packs/parse/resolve-local-names.yaml— the reshape in isolation: threefiboreferences rewrite to the single cactus@name,@localmarkers dropped, no errors.eo-packs/parse/resolve-local-names-duplicate.yaml— two>> dupin one file produce theresolve-local-namesduplicate-handle error.SuffixTest—>> fiboyieldsForm.AUTOcarrying the handle;>>! fibocombines const with the handle; trailing garbage after the handle is still rejected (trailing-non-suffix-autotypo pack updated).All
eo-parsertests pass (959, incl. the parse packs); qulice, xcop and yamllint are clean. I also verified the full parse train on the Fibonacci example end-to-end: allfiboreferences resolve to the single cactus@namewith zero errors — identical to the resolved XMIR of the existingsnippets/fibo.yaml(which uses> f), so runtime behaviour is unchanged.The diff is kept under the 200-line pr-size limit (197). To stay within it, the runtime
SnippetITsnippet was deferred to a follow-up — its program is the existingsnippets/fibo.yamlwith> f→>> fibo, and the resolution is already covered by the isolation packs and the full-train check above. Happy to add it (or split the duplicate-handle safeguard out) if you'd prefer a different balance.🤖 Generated with Claude Code
Generated by Claude Code