Download pdf format

Transcript
7.4.3
More details about rpc goal execution
Variables
As explained in Section 7.3.6, ECLi PSe variables are always represented by the null token, when
rpc is invoked with a CompoundTerm parameter. When used in an rpc goal, each null token
represents a different variable. Using CompoundTerm you cannot represent a goal with multiple
occurrences of a single variable. So, for example the following Java code will output q(b, b)
for the first rpc invocation and q(a, b) for the second.
...
eclipse.rpc("assert(q(a, b))");
eclipse.rpc("assert(q(b, b))");
System.out.println(eclipse.rpc("q(X, X)"));
System.out.println(eclipse.rpc(new CompoundTermImpl("q", null, null)));
...
Nondeterminism
The rpc feature does not support the handling of nondeterminism in the execution of the
ECLi PSe goal. If the goal succeeds, control is returned to Java immediately after the first
solution to the goal is found in ECLi PSe . All choice-points thereafter are ignored. So, for example, although the first ECLi PSe goal below would leave choice-points, it would be equal in
effect to the second.
...
result = eclipse.rpc("member(X, [1, 2, 3, 4, 5])");
...
result = eclipse.rpc("member(X, [1])");
This is not a practical problem. It merely implies that if you are using nondeterminism to
generate multiple solutions, you should collect these on the ECLi PSe side using a meta-level
built-in predicate such as findall/3 and then return the result to Java.
Concurrent invocations of rpc
Note that the rpc method is synchronized. Therefore if, while one Java thread is currently
executing an rpc invocation, a second Java thread tries to invoke the rpc method of the same
EclipseConnection, the second thread will block until the first thread’s rpc invocation returns.
Nested invocations of rpc
During the execution of the rpc method, control is transferred to ECLi PSe . Due to the QueueListener feature which is discussed in Section 7.5, control is sometimes temporarily returned to Java
before the ECLi PSe execution has finished. It is possible for this Java code itself to invoke rpc,
thus leading to nested rpc invocations. Nested rpc invocations should not cause any problems.
63