gprolog icon indicating copy to clipboard operation
gprolog copied to clipboard

hand written C code lacks some garbage collection.

Open Jean-Luc-Picard-2021 opened this issue 1 year ago • 0 comments

Try this:

test(X) :- append(Y, X, [1,2,3|Y]). 

I get that GNU Prolog cannot run it indefinitely:

?- test(X).
X = [1,2,3] ? ;
X = [2,3,1] ? ;
X = [3,1,2] ?

?- test(X), fail; true.
%%% Dialog Window with global stack overflow
%%% After dismissing the Dialog Window GNU Prolog exists

Whereas SWI-Prolog can run it indefinitely:

?- test(X).
X = [1, 2, 3] ;
X = [2, 3, 1] ;
X = [3, 1, 2] .

?- test(X), fail; true.
%%% runs indefinitely, you can watch the thread monitor, see how memory is reclaimed
%%% Responds to Ctrl-C and can be aborted, will gracefully return to top-level 

Credits go to:

Marquee in Prolog https://stackoverflow.com/questions/77061142/marquee-in-prolog

Jean-Luc-Picard-2021 avatar Oct 11 '23 09:10 Jean-Luc-Picard-2021