Skip to content

refactor(comp): share C/JS show_chr and list/tuple brackets - #943

Open
This-Is-NPC wants to merge 2 commits into
bendlang:mainfrom
This-Is-NPC:refactor/comp-show-readback
Open

This-Is-NPC wants to merge 2 commits into
bendlang:mainfrom
This-Is-NPC:refactor/comp-show-readback

Conversation

@This-Is-NPC

Copy link
Copy Markdown

bend2/comp.ts only. Same language, same Base.

The C and JS showers repeated char-escape rules and list/tuple brackets.
One table now emits both.

  • SHOW_ESC / SHOW_HEX emit show_chr. JS hex-escapes surrogates and
    code points past U+10FFFF the way C already did.
  • SHOW_BR emits Con/Nil as [] and Tuple as ().

Net is about even (+39 / −37). The point is one readback policy, not fewer lines.

SHOW_ESC and SHOW_HEX emit both showers. JS hex-escapes surrogates and
code points past U+10FFFF the way C already did.
SHOW_BR emits Con/Nil as [] and Tuple as () for both C and JS, so the
bracket map is one table instead of two if-chains.
@zxv

zxv commented Sep 22, 2026

Copy link
Copy Markdown

rescuing PR by commenting (github bug hid it temporarily)

@nicolas-abril nicolas-abril self-assigned this Sep 22, 2026
@nicolas-abril

Copy link
Copy Markdown
Collaborator

While it is nice that we get the shared behaviour show_chr_src and show_br_c obscure the logic significantly and the code no longer follows the organization of the file, so I can't accept it as it is.

I think either hoisting only the part that is shared but keeping the C/JS skeletons there or applying just the C escape logic to JS would be good solutions

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