Suppose I have the following code, which prints It works!
if a term is a string using the predicate string/1
:
Term string = org.jpl7.Util.textToTerm("\"test\"");
Query testQuery = new Query("string",string);
if(testQuery.hasMoreSolutions()) {
System.out.println("It works!");
}
This does not print anything, which is not what I expected.
Even more strange, replacing the query with new Query("atom",string)
now does work properly, which mean that string is passed as an atom instead of an SWI-Prolog 7 string, even though the text I gave the JPL library to parse uses the double quotes which are the string delimiters, not the atom delimiters.
What's even weirder is that the Java debugger tells me that the Term string
has name test
(without the quotes) and type string
! So textToTerm
seems to produce a string which is correct, but the Term itself is passed as an atom anyway!
Is that a bug, or is it default behavior?
EDIT: the JPL 7 docs states that
SWI Prolog V7 strings are represented in JPL7 as Atoms whose type is "string"
So is there just no way to actually pass real strings to queries?