Skip to content

JS WAM: compiled string literals as V.String - #4206

Open
s243a wants to merge 2 commits into
grok/wamjs-string-polishfrom
grok/wamjs-string-literal
Open

JS WAM: compiled string literals as V.String#4206
s243a wants to merge 2 commits into
grok/wamjs-string-polishfrom
grok/wamjs-string-literal

Conversation

@s243a

@s243a s243a commented Aug 31, 2026

Copy link
Copy Markdown
Owner

D34/D35 residual: compiled "hi" literals become V.String on the JS path without adding a string(_) Class to the shared classifier.

Branched from grok/wamjs-string-polish and extended it (net additions). INTEGRATION_PATCH.md §0 records the shared-file design.

Design (safe: no new Class)

  1. quote_wam_constant/2 — Prolog string(Value) emits "..." (escape \\ and "). Atoms stay bare/single-quoted; numbers unchanged.
  2. wam_classify_constant_token/2 — double-quoted token → strip quotes → atom(Name). Classifier still returns only atom | integer | float.
  3. New exported wam_constant_token_is_string/1 — true iff the raw token has outer double quotes. Only JS reads it.
  4. JS constant_to_js_term/2 builds V.String(...) when that signal is true. T5 chain compares .tag === "string"; T6 atom-hash skips string tokens.

Other runtimes intern the stripped name as an atom — today's behavior.

Tests (local, all green)

  1. tests/test_wam_javascript_builtins.pl including probe_string_literal / string_literal_output (V.String("hi") in generated JS; Node writeq"hi")
  2. tests/test_wam_javascript_lowered.pl and tests/test_wam_javascript_fact_sources.pl
  3. Full-fleet: CONFORMANCE_TARGETS=python,go,rust,c,cpp → green, no xfail (48-query classics each). scala/elixir/wat/haskell/kotlin/fsharp/r skipped here (no toolchain); CI covers them. CONFORMANCE_TARGETS=javascript exits 0 (adapter unpatched; local 48-query stand-in 48/48)
  4. SWI vs Node: compiled "hi"string(X) true, atom(X) false, writeq "hi"

Residuals

  • Fact-source JSON/TSV cells still intern as atoms
  • Brace terms {a} not special-cased in writeq
Open in Web Open in Cursor 

cursoragent and others added 2 commits August 31, 2026 18:08
quote_wam_constant/2 spells string(Value) with outer double quotes.
The shared classifier still returns atom(Name) for those tokens; JS
reads wam_constant_token_is_string/1 and emits V.String.

Co-authored-by: johns243a <johns243a@gmail.com>
python/go/rust/c/cpp each ran the 48-query suite green locally.

Co-authored-by: johns243a <johns243a@gmail.com>
@s243a
s243a marked this pull request as ready for review August 31, 2026 18:12
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.

2 participants