Closed infradig closed 4 months ago
zx81(X,Y) :- Y is X*1.
main(0) :- !.
% main(I) :- zx81(I,I), I2 is I-1, main(I2). % Good
% main(I) :- zx81(I,M), I2 is I-1, main(I2). % Bad, Var M eats memory
% main(I) :- zx81(I,_), I2 is I-1, main(I2). % Bad, Var _ eats memory
Yes, it's the call to xz81/2 (when you get var/var unification) that causes main/1 not to be TCO. I know why just haven't worked out a solution that doesn't break another test, there may be 2 things to fix.
On Sat, May 25, 2024 at 12:21 PM flexoron @.***> wrote:
zx81(X,Y) :- Y is X*1. main(0) :- !. % main(I) :- zx81(I,I), I2 is I-1, main(I2). % Good % main(I) :- zx81(I,M), I2 is I-1, main(I2). % Bad, Var M eats memory % main(I) :- zx81(I,), I2 is I-1, main(I2). % Bad, Var eats memory
— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/543#issuecomment-2130672067, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEVO3GUMGHW5SOZUNU3ZD7YTTAVCNFSM6AAAAABIHBE6YWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZQGY3TEMBWG4 . You are receiving this because you authored the thread.Message ID: @.***>
All these examples run in constant memory with SWI Prolog:
With Trealla only v.pl does not.