Now I wonder whether it would be possible that
SWI-Prolog does constant folding. Recently it had
introduced macros via (#)/1, but all the constants that
then enter into expressions, can they also be evaluated
at compile time to shorten the expressions, aka constant
folding? My test case was this little clause:
test :- _ is 1/3.
If find that set_prolog_flag(optimize, true)
doesn’t do
constant folding, the 1/3
is not precomputed:
?- vm_list(test/0).
========================================================================
test/0
========================================================================
0 s_virgin
1 i_exit
----------------------------------------
clause 1 (<clause>(0000016890eb1e00)):
----------------------------------------
0 i_enter
1 b_void
2 a_enter
3 a_integer(3)
5 a_integer(1)
7 a_func2((/)/2)
9 a_is
10 i_exit
true.
What are the pros and cons if a Prolog system would do that,
like for example SWI-Prolog?