Skip to content

Add JS WAM ISO/library builtin breadth (sort, lists, atoms, format, assoc) - #4187

Open
s243a wants to merge 1 commit into
grok/wamjs-lowered-emitterfrom
grok/wamjs-builtin-breadth
Open

Add JS WAM ISO/library builtin breadth (sort, lists, atoms, format, assoc)#4187
s243a wants to merge 1 commit into
grok/wamjs-lowered-emitterfrom
grok/wamjs-builtin-breadth

Conversation

@s243a

@s243a s243a commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Add ISO/library builtin breadth (G-W3) to the JS WAM interpreter so sort, list, atom/string, format, and assoc families run under Node and match SWI.

Stack

Branched from grok/wamjs-lowered-emitter.

Families

  • Sort: sort/2, msort/2, keysort/2, sort/4 (integer Key, @</@>/</>), predsort/3, compare/3
  • Lists: append/3, reverse/2, nth0/3, nth1/3, last/2, sum_list/2, max_list/2, min_list/2, list_to_set/2, select/3, include/3, exclude/3
  • Atom/string: atom_concat/3, atom_length/2, atom_chars/2, atom_codes/2, char_code/2, sub_atom/5, atom_string/2, number_codes/2, number_string/2, split_string/4, string_concat/3, string_chars/2, upcase_atom/2, downcase_atom/2
  • Format/IO: format/2, format/3 (~w ~a ~d ~p ~q ~n ~s ~t ~~), tab/1, writeln/1
  • Assoc: empty_assoc/1, list_to_assoc/2, get_assoc/3, put_assoc/4, assoc_to_list/2, assoc_to_keys/2 (list-of-pairs, not AVL)

Partial / follow-up

  • No distinct string tag (atom_string/split_string intern as atoms).
  • format: no ~f / ~r / column positioning / stream sinks other than stdout and atom(A)/string(S).
  • assoc is not SWI's AVL tree.
  • term_variables/2, numbervars/3, =@=/2 still unported.

Testing (green locally)

  • swipl -q -g run_tests -t halt tests/test_wam_javascript_builtins.pl — old probes + 48 classics + new family probes
  • swipl -q -g run_tests -t halt tests/test_wam_javascript_lowered.pl

Interpreter-mode 48-query conformance is unchanged. No shared-file edits (no INTEGRATION_PATCH.md).

Open in Web Open in Cursor 

Port sort, list, atom/string, format, and assoc families into the Node
WAM interpreter so probes match SWI. Multi-solution modes (append split,
atom_concat reverse, sub_atom, select, nth0) use a shared enum choice
point. format covers ~w ~a ~d ~p ~q ~n ~s ~t; assoc is a list-of-pairs.

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