Skip to content

refactor(builtin): <+>-simplify Iter and Map Show and small write sequences - #4197

Merged
bobzhang merged 1 commit into
mainfrom
hongbo/simplify-template-builtin-show
Sep 3, 2026
Merged

refactor(builtin): <+>-simplify Iter and Map Show and small write sequences#4197
bobzhang merged 1 commit into
mainfrom
hongbo/simplify-template-builtin-show

Conversation

@bobzhang

@bobzhang bobzhang commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Part of the <+ template-writing simplification, split out of the closed
#4195 for reviewability.

  • Show for Iter and Show for Map write their delimiters/separators
    through <+ templates with \{cb => ...} writer holes, keeping
    write_object dispatch monomorphic
  • base64 == tail and a FixedArray iterator-test builder collapse into
    single <+ writes

Verified: moon check 0 warnings/0 errors, builtin suite 2988/2988.

Generated with SeekMoon

…equences

- `Show for Iter` and `Show for Map` write their delimiters and separators
  through `<+` templates with `\{cb => ...}` writer holes
- base64 `==` tail and a FixedArray iterator-test builder collapse into
  single `<+` writes

Co-Authored-By: SeekMoon <seekmoon@moonbitlang.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are localized refactors that preserve output semantics, and the updated patterns align with existing <+ usage in builtin without introducing new logic paths.

Pull request overview

This PR continues the ongoing <+ template-writing refactor in builtin by replacing small write_string / write_char sequences with <+ writes, including inline-writer holes (\{cb => ...}) where needed to keep write_object dispatch monomorphic.

Changes:

  • Refactors Show for Iter and Map to emit delimiters/separators via <+ templates (using writer holes for write_object).
  • Simplifies base64 padding output by writing "==" in a single <+ call.
  • Simplifies a FixedArray iterator test’s expected-string builder to a single <+ write per element.
File summaries
File Description
builtin/linked_hash_map.mbt Uses <+ templates (with writer holes) for Map[K,V] Show::output punctuation and key/value emission.
builtin/iterator.mbt Uses <+ templates for Iter[X] Show::output punctuation and separator+element emission.
builtin/fixedarray.mbt Collapses StringBuilder writes in the iter test to a single <+ "\{x}\n" call.
builtin/console.mbt Writes base64 "==" padding via a single <+ call.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 6525

Coverage increased (+0.007%) to 89.2%

Details

  • Coverage increased (+0.007%) from the base build.
  • Patch coverage: 2 uncovered changes across 1 file (3 of 5 lines covered, 60.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
builtin/iterator.mbt 2 0 0.0%
Total (2 files) 5 3 60.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 18204
Covered Lines: 16238
Line Coverage: 89.2%
Coverage Strength: 274532.43 hits per line

💛 - Coveralls

@bobzhang
bobzhang merged commit 5a6dfc3 into main Sep 3, 2026
17 checks passed
@bobzhang
bobzhang deleted the hongbo/simplify-template-builtin-show branch September 3, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants