Hi. The following code using JPL creates compound which tests equivalence of two arguments:
Compound compound = new Compound("\\==", new Term[]{new Atom("c"), new Atom("d")});
After that, when toString()
method is called on that compound, it yields '\=='(a, b)
, which shows two quotation marks around predicate \==
.
According to JPL documentation, the toString()
method returns:
a prefix functional representation of a Compound of the form name(arg1,…), where ‘name’ is quoted iff necessary (to be valid Prolog source text) and each argument is represented according to its toString() method. Lists are represented depending on JPL.LIST_TOSTRING_TEXTUAL
However, when I use the string else where, I have to manually remove those quotation marks. For example:
Compound compound = new Compound("\\==", new Term[]{new Atom("c"), new Atom("d")});
t = Term.textToTerm(compound.toString());
the above code throws an exception:
Exception in thread “main” org.jpl7.PrologException: PrologException: error(syntax_error(undefined_char_escape(‘=’)), string(‘’=='(c, d) . ', 1))
I’m woundering why the quotaiton marks are needed here?