I would like to ask about querying SWI-Prolog from foreign predicates and non-deterministic foreign predicates. I was looking at unifying parameter variables with values returned from a nested query iterated across invocations of a non-deterministic foreign predicate. I was looking at calling
PL_next_solution for a nested query opened in a foreign non-deterministic predicate each time that the non-deterministic foreign predicate was invoked. I’m wondering whether such nested queries are currently possible with SWI-Prolog?
I reviewed the documentation. I wonder why it is the case that “a foreign context can have at most one active query. This implies that it is allowed to make strictly nested calls between C and Prolog (Prolog calls C, calls Prolog, calls C, etc.), but it is not allowed to open multiple queries and start generating solutions for each of them by calling
PL_next_solution(). Be sure to call
PL_close_query() on any query you opened before opening the next or returning control back to Prolog.” (http://www.swi-prolog.org/pldoc/man?section=foreign-create-query)
Are there any examples of querying SWI-Prolog from deterministic and non-deterministic foreign predicates?