An issue with current_predicate/1

Given the following:
france(eu).
france(french).
germany(eu).
germany(german).
switzerland(german).
switzerland(french).
switzerland(italian).

%% from https://stackoverflow.com/questions/2717508/find-all-clauses-related-to-an-atom
info(Arg, Info) :-
    current_predicate(PredName/1),
    Info =.. [PredName, Arg],
    call(Info).

%% from https://stackoverflow.com/questions/32852148/how-to-list-all-predicates-that-has-an-specific-atom
filter_predicate(PredName, Arity, ParamList) :-
    current_predicate(PredName/Arity),
    append([PredName], ParamList, PredList),
    GlobalArity is Arity + 1,
    length(PredList, GlobalArity),
    Predicate =.. PredList,
    Predicate.

In Tau-Prolog (http://tau-prolog.org/sandbox/) the queries work as expected:
?- info(german, Pred).
Pred = switzerland(german)
Pred = germany(german)

?- filter_predicate(Pred, 1, [german]).
Pred = switzerland
Pred = germany

In Trealla (built on Mac as well as https://php.energy/trealla.html) they return:
?- info(german, Pred).
   Pred = append(<$stream>(0))
;  Pred = b_delete(<$stream>(0))
;  Pred = bb_b_del(<$stream>(0))
;  Pred = bb_del(<$stream>(0))
; Error: syntax error, incomplete, german:1
 Pred = consult(<$stream>(0))
;  Pred = deconsult(<$stream>(0))
;  Pred = display(<$stream>(0))
;  Pred = file_exists(<$stream>(0))
;  Pred = format(<$stream>(0))
;  Pred = germany(<$stream>(0))
;   error(type_error(integer,german),get_code/1).

?- filter_predicate(Pred, 1, [german]).
    error(type_error(predicate_indicator,_7/1),current_predicate/1).

Well Tau only returns user-defined predicates for current_predicate/1.
On Sun, Oct 16, 2022 at 10:01 PM lbuczkow @.***> wrote:

Given the following:
france(eu).
france(french).
germany(eu).
germany(german).
switzerland(german).
switzerland(french).
switzerland(italian).
%% from https://stackoverflow.com/questions/2717508/find-all-clauses-related-to-an-atom
info(Arg, Info) :-
current_predicate(PredName/1),
Info =.. [PredName, Arg],
call(Info).
%% from https://stackoverflow.com/questions/32852148/how-to-list-all-predicates-that-has-an-specific-atom
filter_predicate(PredName, Arity, ParamList) :-
current_predicate(PredName/Arity),
append([PredName], ParamList, PredList),
GlobalArity is Arity + 1,
length(PredList, GlobalArity),
Predicate =.. PredList,
Predicate.
In Tau-Prolog (http://tau-prolog.org/sandbox/) the queries work as
expected:
?- info(german, Pred).
Pred = switzerland(german)
Pred = germany(german)
?- filter_predicate(Pred, 1, [german]).
Pred = switzerland
Pred = germany
In Trealla (built on Mac as well as https://php.energy/trealla.html) they
return:
?- info(german, Pred).
Pred = append(<$stream>(0))
;  Pred = b_delete(<$stream>(0))
;  Pred = bb_b_del(<$stream>(0))
;  Pred = bb_del(<$stream>(0))
; Error: syntax error, incomplete, german:1
Pred = consult(<$stream>(0))
;  Pred = deconsult(<$stream>(0))
;  Pred = display(<$stream>(0))
;  Pred = file_exists(<$stream>(0))
;  Pred = format(<$stream>(0))
;  Pred = germany(<$stream>(0))
;   error(type_error(integer,german),get_code/1).
?- filter_predicate(Pred, 1, [german]).
error(type_error(predicate_indicator,_7/1),current_predicate/1).
—
Reply to this email directly, view it on GitHub
https://github.com/trealla-prolog/trealla/issues/60, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AFNKSETESDHF2JZBWLNWBQLWDPVCFANCNFSM6AAAAAARGKK3E4
.
You are receiving this because you are subscribed to this thread.Message
ID: @.***>

Trealla and also Scryer seem to be wrong here.
On Sun, 16 Oct 2022, 22:01 lbuczkow, @.***> wrote:

Given the following:
france(eu).
france(french).
germany(eu).
germany(german).
switzerland(german).
switzerland(french).
switzerland(italian).
%% from https://stackoverflow.com/questions/2717508/find-all-clauses-related-to-an-atom
info(Arg, Info) :-
current_predicate(PredName/1),
Info =.. [PredName, Arg],
call(Info).
%% from https://stackoverflow.com/questions/32852148/how-to-list-all-predicates-that-has-an-specific-atom
filter_predicate(PredName, Arity, ParamList) :-
current_predicate(PredName/Arity),
append([PredName], ParamList, PredList),
GlobalArity is Arity + 1,
length(PredList, GlobalArity),
Predicate =.. PredList,
Predicate.
In Tau-Prolog (http://tau-prolog.org/sandbox/) the queries work as
expected:
?- info(german, Pred).
Pred = switzerland(german)
Pred = germany(german)
?- filter_predicate(Pred, 1, [german]).
Pred = switzerland
Pred = germany
In Trealla (built on Mac as well as https://php.energy/trealla.html) they
return:
?- info(german, Pred).
Pred = append(<$stream>(0))
;  Pred = b_delete(<$stream>(0))
;  Pred = bb_b_del(<$stream>(0))
;  Pred = bb_del(<$stream>(0))
; Error: syntax error, incomplete, german:1
Pred = consult(<$stream>(0))
;  Pred = deconsult(<$stream>(0))
;  Pred = display(<$stream>(0))
;  Pred = file_exists(<$stream>(0))
;  Pred = format(<$stream>(0))
;  Pred = germany(<$stream>(0))
;   error(type_error(integer,german),get_code/1).
?- filter_predicate(Pred, 1, [german]).
error(type_error(predicate_indicator,_7/1),current_predicate/1).
—
Reply to this email directly, view it on GitHub
https://github.com/trealla-prolog/trealla/issues/60, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AFNKSETESDHF2JZBWLNWBQLWDPVCFANCNFSM6AAAAAARGKK3E4
.
You are receiving this because you are subscribed to this thread.Message
ID: @.***>

Another thing I've noticed about Trealla's current_predicate/1 is that it doesn't except a single variable as input like:
?- current_predicate(X).
X = foo/1 ; ...

but Scryer and Tau are fine with that.

In the ISO Prolog Core standard, current_predicate/1 is specified to only return user-defined predicates.

Pushed additional tests for the Prolog standard current_predicate/1 predicate to Logtalk's Prolog standards compliance suite. the new tests exposes one of the bugs in Trealla's implementation.

Closing this as I believe it's fixed.

Yes, it works now. Thanks!


Task/photo refactor

Pull Request Test Coverage Report for Build<PHONE_NUMBER>

1 of 1 (100.0%)  changed or added relevant line in 1 file are covered.
No unchanged relevant lines lost coverage.
Overall coverage remained the same at 68.683%

Totals

Change from base Build<PHONE_NUMBER>:
0.0%

Covered Lines:
318

Relevant Lines:
463

💛  - Coveralls