[eclipse-clp-users] Function call

From: Christian Giffhorn <chrgiffhorn_at_...6...>
Date: Tue, 13 Mar 2012 00:46:21 +0100
hi all,

 i am still experiencing with the eclipse interface and still have
problems to start a prolog function from the C++ side. i try to show
it to you with the golog interpreter from Reiter, and the common
example Programm.

On Prolog side i can make this call
" do(control, s0, S)."

And get this Answer:
"S = open do down(0) do close do open do turnoff(5) do up(5) do close
do open do turnoff(3) do down(3) do s0
Yes (0.00s cpu, solution 1, maybe more)"

if i try the same with C++, my program should look like this:

"#include "eclipseclass.h

int main()
{
                ec_init();

		EC_ref States;
	
		post_goal(term(EC_functor("=",2), States, EC_atom("S")));
		
        post_goal(term(EC_functor("compile",1),"//Z/exchange/PrologTest/Golog/elevator.pl"));

        if(EC_resume() != EC_succeed)
		{
			cout << "Compilation failed" << endl;
			exit(-1);
		} else
		{
			cout << " Compilation succes" << endl;
		};

		
		post_goal(term(EC_functor("do",3), EC_atom("control"),
EC_atom("s0"), States));
		
		if(EC_resume() != EC_succeed)
		{
			cout << "succees" << endl;
        }

        ec_cleanup();
	return 0;
}

That how i think it should work, but at the end of compilation the
program crashes, and the debugger leads me to the deconstructor of the
ref(i can even make a cout happen after the cleanup). The example
program to test the c++ enviroment, works fine, i noticed some weird
thing in the past when i still had the code included for the
input/output test it shows me a failure in the the output code like
that: do(control, s0, "S") i couldn't reconsturate it but i got it
with an EC_atom(S) call without the ref.

I am also not hundert percent sure, how the prolog interpreter display
the "history" here, maybe i this leading to the error. Else i will
test it out later.



Received on Mon Mar 12 2012 - 23:46:29 CET

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST