Passing Java Objects to Predicates

Fernando Ribeiro, created Jan 25. 2015 I am getting the "Argument shouldn't be a variable" error with the following code: Java public static Object createConnectionFactory() { ... } public static Object createConnection(final Object connFactory) { ... } Jekejeke Prolog foreign(create_connection_factory/1, 'ActiveMQLibrary', createConnectionFactory). foreign(create_connection/2, 'ActiveMQLibrary', createConnection('Object'). create_connection_factory(ConnFactory). create_connection(ConnFactory, Conn). How can create_connection take the Java object returned by create_connection_factory?

Comments

Re: Passing Java Objects to Predicates

Fernando Ribeiro, created Jan 26. 2015 I think that did the trick, will continue to write the library. Thanks!

Re: Passing Java Objects to Predicates

Jan Burse, created Jan 26. 2015 I don't see exactly from which query you get the error. So I have to guess. Did you try? ?- create_connection_factory(ConnFactory). ?- create_connection(ConnFactory, Conn). Try instead: ?- create_connection_factory(ConnFactory), create_connection(ConnFactory, Conn). Or: ?- create_connection_factory(ConnFactory), assertz(my_factory(ConnFactory)). ?- my_factory(ConnFactory), create_connection(ConnFactory, Conn). Prolog does not work like Erlang. From query to query variables are fresh. Bye