Various options are floating around. One option is to use DCGs or EDCGs to hide these variables. I’ve also seen notations that represent a pair N0,N1 as a single argument that is macro-expanded into a pair. This requires the pair to be consecutive arguments to predicates and (thus) won’t help here. For the pure Prolog way, one needs some conventions. I typically call them X0, X1, … X if a predicate makes X go through a number of state transitions. A good example is when X is an assoc and we do several modifications on the assoc.
I think your fib/2 example is perfectly fine. Maybe the OUT vs F1/F2 is a little confusing and OUT could be name simply F. Prolog remains a bit clumsy for implementing pure functions. Of course we can use one of the many functional notation extensions. Most suffer from corner cases or unpleasant syntax. Prolog is a relational language. This makes it shines for dealing with relations
For the pure Prolog way, one needs some conventions. I typically call them X0, X1, … X if a predicate makes X go through a number of state transitions. A good example is when X is an assoc and we do several modifications on the assoc.
I don’t quite understand this convention. Could you explain it further?
In the fib/2 example, are the N1, N2 and F1, F2 what you called “X go through a number of state transitions” ?
I feel somewhat sympathetic in that the syntax of prolog variables should be allowed to be extended. The |…| syntax sounds nice for me. Boolean variables library(clpb) are only Prolog variables. So, for ZDD library I extended the syntax for readability. Currently in ZDD, Prolog variables and ground atoms are allowed for propositional variables. So far I met no problems. I guess no problems for any prolog terms provided that it is free from reserved logical operators. Internally the zdd library does simple book keeping for this purpose of generating index using assoc. Compared with ZDD’s core task, this book keeping is negligible.