| Did you know ... | Search Documentation: |
| Pack starlog -- IMPLEMENTATION_SUMMARY.md |
Successfully implemented a new Starlog-in-Prolog library that allows developers to write Starlog syntax directly in normal `.pl` files and run it immediately without converting files, as specified in Requirements.
starlog_to_prolog_cli.pl - CLI tool for converting Starlog files to Prologprolog_to_starlog_cli.pl - CLI tool for converting Prolog files to Starlogvar_utils.pl - Variable renaming utilities for CLI converterstest_round_trip1.sh - Round-trip conversion tests:, &, •)tests/test_basic.pl - Basic functionality tests (6 tests)tests/test_nested.pl - Nested expression tests (5 tests)tests/test_arithmetic_is.pl - Arithmetic preservation tests (5 tests)tests/test_mixed_prolog_starlog.pl - Mixed code tests (5 tests)examples.pl - Comprehensive examples demonstrating all acceptance tests from Requirements (7 examples)README.md with complete usage documentation, examples, and API reference# Old workflow: Convert files, then run cd starlog_files swipl -q -g main -s ../starlog_to_prolog_cli.pl # Generated *_prolog.pl files
% New workflow: Write and run directly
:- use_module(starlog).
% Write Starlog syntax in your Prolog file
greet(First, Last, Greeting) :-
Greeting is "Hello, " : First : " " : Last : "!".
% It just works!
?- greet("John", "Doe", G).
G = "Hello, John Doe!".
Write Starlog expressions directly in Prolog files:
Result is "a" : "b" % String concatenation
Result is [1,2] & [3,4] % List append
Result is hello • world % Atom concatenation
Result is string_length("x") % Value-returning builtin
The library automatically expands Starlog syntax at load-time using Prolog's goal_expansion and term_expansion hooks.
Complex nested expressions are automatically decomposed:
% Starlog: E is •(A:(B:(D•F)), C) % Expands to: atom_concat(D, F, _G1), string_concat(B, _G1, _G2), string_concat(A, _G2, _G3), atom_concat(_G3, C, E)
Starlog evaluates expressions by default (eval is the default behavior), but provides no_eval and eval for fine-grained control:
% Default evaluation (eval is implicit)
A is 1+1 % A = 2
B is "x":"y" % B = "xy"
% Preserve expressions with no_eval
C is no_eval(1+1) % C = 1+1 (not evaluated)
D is no_eval("x":"y") % D = "x":"y" (not evaluated)
% Force evaluation inside no_eval with eval
E is no_eval(eval(1+1)) % E = 2 (inner eval forces evaluation)
F is no_eval("a" : eval("b":"c")) % F = "a":"bc" (only eval part evaluated)
Standard Prolog arithmetic expressions remain unchanged:
X is 1+2 % Treated as arithmetic, not Starlog X is Y * 5 % Also arithmetic
Use starlog_call/1 for REPL queries:
?- starlog_call(A is "x":"y"). A = "xy".
Register custom value-returning builtins:
?- starlog_register_value_builtin(my_func, 2, my_func). % Now: Out is my_func(A,B) expands to my_func(A,B,Out)
Enable debug output to see expansions:
?- starlog_set_debug(true).
?- starlog_call(A is "x":"y").
Expanding goal: A is "x":"y"
Expanded to: string_concat("x","y",A)
A = "xy".
The library supports 100+ built-in predicates across categories:
starlog_registry.pl for the complete list.All tests passing:
All requirements from Requirements have been met:
✅ Direct entry of Starlog goals in Prolog source files
✅ Automatic expansion using goal_expansion/term_expansion
✅ Support for :, &, • operators
✅ Value-returning builtin support
✅ Nested expression decompression
✅ Arithmetic is/2 preservation
✅ Extensibility hooks
✅ Debug output
✅ Compatibility with SWI-Prolog 8.x+
✅ Works in interactive queries and loaded modules
The old CLI conversion workflow (prolog_to_starlog_cli.pl and starlog_to_prolog_cli.pl) has been completely replaced with the new in-Prolog expansion approach. Users who relied on the CLI tools will need to:
starlog library instead of using CLI tools
:- use_module('/path/to/starlog').
Or add to your SWI-Prolog library path.
BSD-3-Clause (unchanged)
Implementation Date: 2025-12-24 Status: Complete and tested