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:
+1
-2
@@ -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].
|
||||
|
||||
Reference in New Issue
Block a user