-
Here's some synthentic code that demonstrates an issue I can't seemingly get a good answer for in the manual. :- object(tab1).
:- table(t/1).
t(X) :- writeln(X).
:- public(test/0).
test :- t(0), t(0).
:- end_object.
:- object(tab1(_X)).
:- public(test/0).
test :- tab1::test.
:- end_object. If I call ?- tab1(0)::test.
0
true.
?- tab1(0)::test.
true.
?- tab1(1)::test.
0
true. I am, however, trying to find a way to have a global table (my actual code does some slow networking interaction in the tabled function). So far, I solved this by moving the t/1 predicate outside of any object and calling it from the user object (using Is there a better way to solve this? Have I missed anything in the manual? I apologize if it is described somewhere. I've checked the tabling example. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Which backend Prolog system are you using? |
Beta Was this translation helpful? Give feedback.
-
The issue here is that the message sender is a different term when you give a different parameter (e.g. A workaround is to send tabled predicate messages from a non-parametric objects. E.g. :- object(tab1(_X)).
:- public(test/0).
test :- {tab1::test}.
:- end_object. As you mentioned, moving the tabled predicate to plain Prolog also solves the problem. In this case, if you don't want to use the :- uses(user, [t/1]). |
Beta Was this translation helpful? Give feedback.
The issue here is that the message sender is a different term when you give a different parameter (e.g.
tab1(0)
andtab1(1)
). The sender is part of the implicit execution context and that difference means that one table will be constructed fro which different sender. Solving this issue would require the backend Prolog implementation of tabling to provide a solution to ignore the implicit execution context argument when constructing the table. But that solution doesn't exist currently.A workaround is to send tabled predicate messages from a non-parametric objects. E.g.
As you mentioned, moving the tabled pred…