JS WAM: string_length/2 and writeq/~q nested quoting - #4205
Open
s243a wants to merge 1 commit into
Open
Conversation
Register string_length/2 (string/atom/number, code-point length) and writeq/1. The quoted writer now walks lists and compounds so nested strings render as "…" and atoms quote only when SWI needs it. Co-authored-by: johns243a <johns243a@gmail.com>
s243a
marked this pull request as ready for review
August 31, 2026 13:14
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.
D34 residuals on the JS WAM string tag:
string_length/2andwriteq/1/ recursive~qquoting.Branched from
grok/wamjs-string-tagand extended it (net additions). NoINTEGRATION_PATCH.md.What landed
string_length/2— accepts a string, atom, or number (text form); binds the Unicode code-point length.string_length("abc", N)→N = 3.writeq/1registered. The quoted writer (quoted_term_to_string) is the same pathformat~quses. It now recurses through lists and compounds:writeq("ab")→"ab";writeq(["ab", foo])→["ab",foo]write/1is unchanged (string text unquoted; list spacing still", ").Atom-quoting subset (SWI-like, pragmatic)
Unquoted:
[],!,;,{},^[a-z][A-Za-z0-9_]*$, and ISO graphic atoms (#$&*+-./:<=>?@^~\) except the lone atom.(end-of-term). Quoted otherwise; escapes\\and\'only.Tests (local, all green)
tests/test_wam_javascript_builtins.plincludingprobe_string_polishandstring_polish_outputtests/test_wam_javascript_lowered.plandtests/test_wam_javascript_fact_sources.plCONFORMANCE_TARGETS=javascriptharness exits 0 (adapter still unpatched; local 48-query stand-in stays 48/48)string_length,writeq(string / quoted atom / bare atom /[]),writeof a string, and nested~qResiduals (unchanged / documented)
"foo"literals still collapse to atoms (wam_target.plout of scope)\n/\tescapes in writeq{a}not special-cased