Sathish Kumar Murugesan wrote: > > I've got a problem with arrays. I need to declare a 2 > dimensional array in a program that is to be embedded > in C++. How do I proceed with the functors [] and dim > in the post_goal function? And how do I use the > functor [] in the post_goal function? There should be no difference to other functors, e.g. to construct the term [](1,2,3) you write term(EC_functor("[]",3),1,2,3) > Or is there any > other better way to implement arrays while embedding > in a C++ program? The best way depends on what operations you want to do on the arrays on the C++ and on the Eclipse side. See the example files eg_cc_sendmore.cc and eg_cc_sendmore.cc for related examples. > > And how do I do the following from C++? > > List=[A,B,C,D], Arr =.. [array|List]. It is possible, but don't make the mistake of trying to write large parts of your Eclipse program "through the C++ interface". Try to miminize the interface between the languages. Make simple calls from C++ that pass only the absolutely necessary arguments. In your example, decide whether to use either the array or the list on the C++ side, and pass only that through the interface. E.g. if you decide to use the array (= structure) on the C++ side, you could construct it in C++ EC_term arr = term(EC_functor("array",4),...) and pass it as an argument to an Eclipse goal post_goal(EC_functor("p",1),arr) and in the Eclipse code you would have p(Arr) :- Arr =.. [array|List], ... or it might be easier to construct the array in Eclipse (using functor/3 or dim/2) and pass it to C++ where it can be deconstructed using int EC_word::functor(EC_functor *) and int EC_word::arg(const int,EC_word&) -- Joachim Schimpf / phone: +44 20 7594 8187 IC-Parc, Imperial College / mailto:J.Schimpf@ic.ac.uk London SW7 2AZ, UK / http://www.icparc.ic.ac.uk/eclipseReceived on Tue Mar 06 13:39:40 2001
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:07 PM GMT GMT