Historically Prolog had an advantage over other languages because it provided backtracking. But a couple of imperative languages now provide at least generators as well:
-
JavaScript yield:
Theyield
keyword is used to pause and resume a generator function
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield -
Python yield:
PEP 255 – Simple Generators
PEP 255 -- Simple Generators | Python.org -
C yield:
Some hack with long jump
https://stackoverflow.com/q/17478264/502187
I am not sure. But the advantage of yield is that it can make a scope of a choice point that includes loops. Whereas in Prolog tail recursion, used for loops, somehow kills and creates choice points.
What happens in Picat if it has non-determinism inside loop and assigment?
Are there some opportunities to improve Prolog? Asking for a friend…