Scryer-prolog: inifinite backtracking loop with call(G)

Created on 10 May 2020  路  4Comments  路  Source: mthom/scryer-prolog

When I rename a functor name before calling it, I get an infinite backtracking loop:

?- [user].
:- use_module(library(format)).
:- use_module(library(dcgs)).

prefix_test(0).

run(G) :-
  G =.. [F, A],
  phrase(format_("prefix_~w", [F]), Q),
  atom_chars(F0, Q),
  G0 =.. [F0, A],
  call(G0).

?- run(test(X)).
   X = 0
;  X = 0
;  X = 0
;  X = 0
;  X = 0
;  X = 0
;  X = 0
;  X = 0
;  X = 0
;  X = 0
;  X = 0
;  ...
?-

I do not have this behavior on other prologs

xsb:

| ?- [user].
[Compiling user]
prefix_test(0).

run(G) :-
  G =.. [F, A],
  fmt_write_string(F0, "prefix_%s", args(F)),
  G0 =.. [F0, A],
  call(G0).
[user compiled, cpu time used: 0.0110 seconds]
[user loaded]

yes
| ?- run(test(X)).

X = 0;

no
| ?-

swipl:

?- [user].
|: prefix_test(0).
|: 
|: run(G) :-
|:   G =.. [F, A],
|:   format(atom(F0), 'prefix_~w', [F]),
|:   G0 =.. [F0, A],
|:   call(G0).
|: ^D% user://1 compiled 0.00 sec, 2 clauses
true.

?- run(test(X)).
X = 0.

?-

Most helpful comment

OK I just made a git pull and rebuild and now its ok.

for your info it was "v0.8.119-271-g3d68e2b"

I must say you all make an amazing job :+1:

All 4 comments

I can't reproduce it with this version "v0.8.119-284-gd1d36f9" of scryer-prolog. Is it on the current master?

OK I just made a git pull and rebuild and now its ok.

for your info it was "v0.8.119-271-g3d68e2b"

I must say you all make an amazing job :+1:

@cduret: Very nice use of format_//2. This construct is a very versatile building block, and is especially useful due to Scryer's pervasive and efficient use of lists of characters.

Also check out the call/N family of predicates. For instance:

  call(F0, A).

thanks for comments
I have replaced G0 =.. [F0, A], call(G0) by call(F0, A)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jburse picture jburse  路  5Comments

notoria picture notoria  路  3Comments

mkohlhaas picture mkohlhaas  路  3Comments

triska picture triska  路  3Comments

triska picture triska  路  3Comments