JPL - Release notes - 3.0.0

This release is a work-in-progress, and is being made available only to a few enthusiasts who don't mind the likelihood that the API will change before 3.x becomes stable.

Java API: new Variable semantics

A Variable must be created with a name, e.g.
new Variable("X")
or as an anonymous variable
new Variable("_")
or as a dont-tell-me variable
new Variable("_Q")
Each binding within a solution is now indexed by the name of its associated Variable, hence
solution.get("X")
New variables returned in bindings are given new, sequential names, e.g. "_283".
 
Each Variable instance within a Java application is just a lexical token in the alternative Prolog concrete syntax which Term and its subclasses comprise.  Two instances of Variable("X") are no different from one shared instance: you are free to reuse such lexical elements, but this has nothing to do with the sharing of variables which can occur within a Prolog engine.
 
The bindings of anonymous and dont-tell-me variables (i.e. those whose names begin with an underscore character) are not returned to Java: use them to avoid the computational time and space costs of constructing Term representations of bindings in which you are not interested.

Java API: easier Term and Query construction

Now that Variables are named, and bindings are keyed by the names of variables, it is easier to construct Term (and hence Query) instances.
 
This utility (NB liable to be renamed or moved into a different class) converts a valid Prolog source text representation of a term into a corresponding Term hierarchy:
Term jpl.Util.textToTerm( String sourcetext)
A new (in JPL 3.0.0) Query constructor
Query( String sourcetext)
allows queries to be created from source text, e.g.
new Query("findall(_A,current_atom(_A),_As),length(_As,N)")
and oneSolution(), allSolutions() and nextSolution() will return bindings of N (but not of the dont-tell-me variables _A and _As), e.g.
q.oneSolution().get("N")
returns a jpl.Integer representing the Prolog integer value to which N was bound by the successful call of the query.

Java API: deprecated methods

use Query.hasSolution() instead
use Query.close() instead

Java API: fixes

array methods inherited from java.lang.Object are now callable, e.g.

Java API: planned or under consideration

jpl_call(+Obj, +Class:Method, +Args, -Result)
jpl_new('Timestamp', X, R)
when we mean
jpl_new('javax.sql.Timestamp', X, R)
public final Term[] args;
Paul Singleton
Wednesday 4th February 2004