Re: [eclipse-clp-users] Calling predicates from a module using Java

From: Joachim Schimpf (Independent Contractor) <jschimpf_at_...5...>
Date: Wed, 28 May 2008 12:58:33 +0100
Wit Jakuczun wrote:
> Thank you for the answer. I have realised my stupid mistake a minute
> after sending  a post to a group.
> 
> By the way I would like to clarify another issue.
> Suppose I have a predicate: test.
> 1) test has arity 1:
>   test(V) :- V is 1.
>   Now using rpc:
>   CompoundTerm ret = engine.rpc(
>                                                 new CompoundTermImpl(
>            "test",
>             null)
>    );
> 
>   does not work. I get a following exception
> com.parctechnologies.eclipse.CompoundTermImpl.<init>(CompoundTermImpl.java:68)
> 
> 2) Having test defined as follows:
>   test(V, N)  :- V is 1.
>   the following Java code works:
>   CompoundTerm ret = engine.rpc(
>                                                 new CompoundTermImpl(
>            "test",
>             null,
>             new Integer(3))
>    );
> 
> Why 1) throws an exception and 2) does not? I would like
> to have a predicate defining variable, that is of arity 1 ( like test(V)  ).
> 


I supose this is because the CompoundTermImpl constructor with 2 arguments
is overloaded as

public CompoundTermImpl(java.lang.String functor, java.lang.Object[] args)
public CompoundTermImpl(java.lang.String functor, java.lang.Object a1)

and giving a typeless null value for the 2nd argument makes it ambiguous.


-- Joachim
Received on Wed May 28 2008 - 04:58:48 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST