nullary combinator as definition.

That eliminates all the recursive calls to thun/3 (outside of thun itself, which is tail recursive.)  That means that this Joy interpreter is now fully CPS.

All state is contained in the stack and expression, nothing is hidden in the Prolog "call stack".
This commit is contained in:
Simon Forman 2019-07-15 11:20:13 -07:00
parent d3313ce4a7
commit 4ea1a5527e
1 changed files with 1 additions and 2 deletions

View File

@ -83,8 +83,6 @@ literal(_/_).
Functions
*/
func(nullary, [P|S], [X|S]) :- thun(P, S, [X|_]). % Combinator.
func(cons, [A, B|S], [[B|A]|S]).
func(swap, [A, B|S], [B, A|S]).
func(dup, [A|S], [A, A|S]).
@ -159,6 +157,7 @@ ii ≡ [[dip], dupdip, i].
infra [swons, swaack, [i], dip, swaack].
make_generator [[codireco], ccons].
neg [0, swap, -].
nullary [stack, popd, [i], infra, first].
of [swap, at].
pm [[+], [-], cleave, popdd].
popd [[pop], dip].