I wasn’t sure where to discuss this.
main :-
_rel=[X]>>(writeln(X),Y=3,call(_rel,Y)),
call(_rel,2).
?- main.
2
false.
See above code. In my understanding, FP closures should be able to be bound to variables then called. That’s possible, however, the above code fails. It seems that’s because,
main2 :-
_rel=[X]>>(writeln(X)),
X=2,
call(_rel,Y).
?- main2.
2
true.
Even the arguments are unified with the surrounding environment. This persists, hence on the second call X is already unified with 2, it fails. I believe this is not fully FP behavior.
- Is this intended? (Perhaps due to being LP the behaviour should be different, or the main use for lambdas is not this.)
- Is it possible to change this with library code?
- Should it be like this, etc.