[eclipse-clp-users] On implementation of post_goal and EC_resume

From: Zhang, Y <y.zhang_at_ttu.edu>
Date: Sun, 21 Jun 2009 10:59:08 -0500
Dear all (and especially Kish),

We are working on answering a sequence of goals incrementally.
We noticed eclipse provides "post_goal" in its interface for C++.
I'd like to know how eclipse process the continuously added goals 
(incrementally)?

I also have a programming problem. I write this piece of code:

---
	...
    ec_exec_string("compile('test.pl')",0);
 
    post_goal(term(EC_functor("q",1),X));
    if (EC_resume(Start)==EC_succeed){
        ((EC_word)X).is_atom(&r1);
        cout << "succeed" << " X=" << r1.Name() << endl;
    }
    else cout << "failed q(X)" << endl;
 
    post_goal(term(EC_functor("q", 2), X, Y));
    if (EC_resume(Start)==EC_succeed) {                                   
      cout << "succeed"; 
      if (EC_succeed == ((EC_word)X).is_atom(&r1))  
        cout << " X=" << r1.Name() << " ";
    
      if (EC_succeed == ((EC_word)Y).is_atom(&r2)) {
        cout << " Y=" << r2.Name() << endl;
      }
      else cout << "bad Y " << endl;
    }
    else
        cout << "failed q(X,Y)" << endl;
	...
---
--- test.pl ---
q(a).
q(b).
q(b,c).
--- end of test.pl ---

I got this output

--
succeed X=a
succeed X=b bad Y 
succeed X=b
succeed X=basf Y=c
---

In fact, I expect line 2 to be "succeed X=b Y=c". Any comments on
what's wrong about the program? Thank you.

Yuanlin
Received on Sun Jun 21 2009 - 15:59:15 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET